Announcement Announcement Module
Collapse
No announcement yet.
FlatFileItemReader Reading Past EOF Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • 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
    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?

    Comment


    • #3
      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

      Comment


      • #4
        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

        Comment

        Working...
        X