Fuse 6 is no longer supported
As of February 2025, Red Hat Fuse 6 is no longer supported. If you are using Fuse 6, please upgrade to Red Hat build of Apache Camel.이 콘텐츠는 선택한 언어로 제공되지 않습니다.
2.6. Binding CSV Records to Java Objects
- Read the following to learn how to CSV records to Java objects. In this example, we will use CSV records for people:
Tom,Fennelly,Male,4,Ireland Mike,Fennelly,Male,2,Ireland
Tom,Fennelly,Male,4,Ireland Mike,Fennelly,Male,2,Ireland
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Input this code to bind the record to a person:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - Input the following code and modify it to suit your task:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - To execute the configuration, use this code:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - You can create Maps from the CSV record set:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow - The configuration above produces a map of person instances, keyed to the firstname value of each person. This is how it is executed:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow Virtual models are also supported, so you can define the class attribute as ajava.util.Map
and bind the CSV field values to map instances which are, in turn, added to a list or map.