Announcement Announcement Module
Collapse
No announcement yet.
How to read this file? Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to read this file?

    Hi,

    If i have an object structure like:

    Code:
    public class Person{	
        String name;
        int age;
        List<Phone> phoneList;
    
        @Override
        public String toString(){
           return
           ToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE);
        }
    }
    Code:
    public class Phone{	
        
        String number;
        boolean isActive;
    
        @Override
        public String toString(){
           return
           ToStringBuilder.reflectionToString(this, ToStringStyle.SIMPLE_STYLE);
        }
    }
    If i write using FlatFileItemWriter, it gets written like:

    Code:
    Jack,26[9871006803,true, 9871858602,false]
    Susan,28[9882342232,true, 9090909002,true, 9876764538,false]
    I am using simplest of the writers:

    Code:
    FlatFileItemWriter<Person> writer = new FlatFileItemWriter<Person>();
    writer.setResource(new FileSystemResource("PersonList.txt"));
    writer.setLineAggregator(new PassThroughLineAggregator<Person>());
    writer.open(new ExecutionContext());
    writer.write(MYLISTGOESHERE);

    How should i write the reader to get back fully loaded Person object? Please guide.


    Best Regards.
    Last edited by jagpreetsingh83; Jan 11th, 2010, 04:42 PM.
Working...
X