Announcement Announcement Module
Collapse
No announcement yet.
Reading ISO-8859-1 file Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Reading ISO-8859-1 file

    I need to read a ISO-8859-1 encoded file and write the records to a database.

    It is a properties files, created in Eclipse. Here is an excerpt of that file:

    Code:
     campo.ver.atraceitalancamentosmes=Aceita Lan\u00E7amentos no M\u00EAs?
      campo.ver.atraceitadigitacaocalculo=Aceita Digita\u00E7\u00E3o C\u00E1lculo?
      ver.tipo.liquido=L\u00EDquido
    When I read the file using new PropertiesConfiguration("file.properties") everything works fine: \u00E7 is replaced by ç, \u00ED is replaced by Ã*, and so on. *EDIT: it looks like the forum doesn't like special characters neither, lol. They are being replaced by weird chars (ç and Ã*)


    However, when I use spring batch to read the file, the strings are stored "as is" to in the DB (\u00E7 is stored as \u00E7).


    I'm using the FlatFileItemReader bean to perform the reading, here is the configuration of that bean:

    Code:
     <bean
              id="read"
              class="org.springframework.batch.item.file.FlatFileItemReader"
              scope="step">
              <property
                  name="resource"
                  value="file:#{jobParameters['path.properties']}" />
              <property
                  name="linesToSkip"
                  value="0" />
              <property
                  name="encoding"
                  value="ISO-8859-1" />        
              <property name="lineMapper">
                  <bean class="org.springframework.batch.item.file.mapping.DefaultLineMapper">
                      <property name="lineTokenizer">
                          <bean class="org.springframework.batch.item.file.transform.DelimitedLineTokenizer">
                              <property
                                  name="delimiter"
                                  value="=" />
                              <property
                                  name="names"
                                  value="KEY,VALUE" />
                          </bean>
                      </property>
                      <property name="fieldSetMapper">
                          <bean class="my.Mapper" />
                      </property>
                  </bean>
              </property>
      </bean>
    Last edited by felipe.gdr; Dec 5th, 2013, 06:05 AM. Reason: explanation about special characters in the forum

  • #2
    Sorry for not getting to this sooner. We are in the process of moving to StackOverflow for our forums.

    This question is probably a better candidate for StackOverflow, perhaps against the #spring-batch tag. If you do post it there, please reply here with the link. Thanks!

    Comment

    Working...
    X