Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

190
Views
BeanIo can't read special caracters

I have a .txt file with ANSI (windows-1252) Encoding i'am able to read it on windows but not on unix.

here is the xml mapping file :

  <beanio>
    <stream name="empData" format="csv">
        <parser>
            <property name="delimiter" value=";"/>
            <property name="alwaysQuote" value="false"/>
            <!--<property name="quote" value='' />-->
        </parser>    

            <record name="emp" class="com.MyClass" >
            <field name="name" />
            <field name="job" />
            <field name="adress"/>  
       </record>
    </stream>
</beanio>

Java Side :

StreamFactory factory = StreamFactory.newInstance();

    InputStream in = this.getClass().getClassLoader()
            .getResourceAsStream("mapping.xml");

    Reader reader = new InputStreamReader(this.getClass().getClassLoader()
            .getResourceAsStream("countries.txt"));
    factory.load(in);

    BeanReader beanReader = factory.createReader("empData", reader);
    Gson gson = new Gson();
    /*Object bean =new Object();*/
    Object record = null;
    while ((record = beanReader.read()) != null) {
        System.out.println(beanReader.getRecordName() + ": "
                +((MyClass)record).getCountry());
    }

Result : line : France

line : S??o Paulo should be (São Paulo) windows OK but unix is KO

line : USA

line : China

Any idea ?

FYI : i already tried to set Charset to UTF-8 java side .

new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("clearings.txt"), Charset.forName("UTF-8"));
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

It's a bit late but... if you have a ANSI file a.k.a. ISO-8859-1, you have to set the InputStreamReader charset as ISO-8859-1, not UTF-8.

Reader reader = new InputStreamReader(this.getClass().getClassLoader().getResourceAsStream("clearings.txt"), StandardCharsets.ISO_8859_1);
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!