| Author |
How to extract CSV data and bind to bean?
|
James Dekker
Ranch Hand
Joined: Dec 09, 2006
Posts: 215
|
|
Suppose, you have text file which contains the following data delimited by commas: And you have constructed a POJO (bean) which looks like this: How can one go about loading this file into memory, extracting out the commas, and assigning the data to the correct properties inside LineItem? Should it be done inside a Helper class that does both (File I/O and strips out the commas and then binds to the LineItem class)? Or should it also include a 3rd class which binds to to an ArrayList<LineItem> lineItems which would set them to the appropriate properties? Thanks,
|
 |
Remko Strating
Ranch Hand
Joined: Dec 28, 2006
Posts: 893
|
posted

0
|
I would use the java.util.Scanner class. The following link explains the working of the scanner class and gives you an example Scanning text with java.util.Scanner
|
Remko (My website)
SCJP 1.5, SCWCD 1.4, SCDJWS 1.4, SCBCD 1.5, ITIL(Manager), Prince2(Practitioner), Reading/ gaining experience for SCEA,
|
 |
 |
|
|
subject: How to extract CSV data and bind to bean?
|
|
|