Results 1 to 4 of 4

Thread: FlatFileItemReader Reading Past EOF

  1. #1
    Join Date
    Mar 2011
    Posts
    2

    Question FlatFileItemReader Reading Past EOF

    I'm attempting to learn how to use the FlatFileItemReader to read some data exported from my iTunes Library. When it runs, it is reading all of the file data as expected, but it seems to be attempting to read past the last record. It then issues an incorrect token count exception, saying that it was expecting 27 tokens and only found 1.

    Here's the configuration for the reader...


    <bean id="reader" class="org.springframework.batch.item.file.FlatFil eItemReader">
    <property name="resource" value="classpath:AltNation.txt"/>
    <property name="lineMapper">
    <bean class="org.springframework.batch.item.file.mapping .DefaultLineMapper">
    <property name="lineTokenizer">
    <bean class="org.springframework.batch.item.file.transfo rm.DelimitedLineTokenizer">
    <property name="delimiter" value="|"/>
    <property name="names" value="Name, Artist, Composer, Album, Grouping, Genre, Size, Time, DiscNumber, DiscCount, TrackNumber, TrackCount, Year,DateModified, DateAdded, BitRate, SampleRate, VolumeAdjustment, Kind, Equalizer, Comments, Plays, LastPlayed, Skips, LastSkipped, MyRating, Location"/>
    </bean>
    </property>
    <property name="fieldSetMapper">
    <bean class="org.springframework.batch.item.file.mapping .BeanWrapperFieldSetMapper">
    <property name="prototypeBeanName" value="ITunesItem"/>
    </bean>
    </property>
    </bean>
    </property>
    </bean>

    <bean id="ITunesItem" class="org.springframework.sample.batch.example.IT unesItem" scope="prototype"/>

    Do I need an empty row in the file? Some other marker of some kind?

    Thanks.

  2. #2
    Join Date
    Dec 2005
    Location
    Lyon, France
    Posts
    311

    Default

    you don't need an extra-line at the end of the file, on the contrary, there mustn't be any extra line. Did you check the input file?

  3. #3
    Join Date
    May 2008
    Posts
    10

    Default

    Hi!

    perhaps you may want to consider implementing you own record separator policy for the input file. Since we seldom have a direct influence on the file format delivered, it may be an alternative to describe the file specifics in there.

    You may want to scan the reference docs chaper 6.6.2 and the interface org.springframework.batch.item.file.separator.Reco rdSeparatorPolicy.


    Regards


    Werner

  4. #4
    Join Date
    Mar 2011
    Posts
    2

    Default Fixed It. Thanks!

    So, just a mea culpa. As I mentioned, I noticed that my input file (an exported playlist from iTunes) was shown in the directory listing as...

    -rw-r--r--@

    Turns out that the "@", which I had not encountered before, indicates additional hidden attributes. In this case it contains information about what class in Mac OS X should handle the file; essentially, it looks like the resource fork.

    Once I coped the data to a new file, the problem went away.

    Thanks for your quick replies.
    -jim

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •