title: Character encoding while parsing a file with Java on Linux
body: <p>With a java script, I am trying to read a file that contains the name of a file on my Linux filesystem. It points to a file that was generated on a Windows OS and has accents in it's name.</p>
  
  <p>Example of this kind of file "input.csv" :</p>
  
  <pre><code>MYFILE_tést.doc;1
  </code></pre>
  
  <p>The java program parses the file in question and verifies if that file exists. But for those lines containing accents, <code>file.exists()</code> in Java always returns false.</p>
  
  <ul>
  <li>The file "input.csv" is generated in Windows and encoded in ISO-8859-1</li>
  <li>Linux locales are configured like this :</li>
  </ul>
  
  <blockquote>
  <pre><code>   LANG=en_US.ISO-8859-1
     LC_CTYPE="en_US.ISO-8859-1"
     LC_NUMERIC="en_US.ISO-8859-1"
     LC_TIME="en_US.ISO-8859-1"
     LC_COLLATE="en_US.ISO-8859-1"
     LC_MONETARY="en_US.ISO-8859-1"
     LC_MESSAGES="en_US.ISO-8859-1"
     LC_PAPER="en_US.ISO-8859-1"
     LC_NAME="en_US.ISO-8859-1"
     LC_ADDRESS="en_US.ISO-8859-1"
     LC_TELEPHONE="en_US.ISO-8859-1"
     LC_MEASUREMENT="en_US.ISO-8859-1"
     LC_IDENTIFICATION="en_US.ISO-8859-1"
     LC_ALL=en_US.ISO-8859-1
  </code></pre>
  </blockquote>
  
  <ul>
  <li><p>When reading the CSV file in java, i'm forcing the encoding :</p>
  
  <blockquote>
    <p>csvFile = new BufferedReader(new InputStreamReader(new
    FileInputStream(FILE_CSV), "ISO-8859-1"));</p>
  </blockquote></li>
  </ul>
  
  <p>I tried switching to UTF-8 (OS locales + file encoding) or playing with the <code>-Dfile.encoding=ISO-8859-1</code> JVM parameter but still the same problem.</p>
  
  <p>The problem doesn't ocur if i hardcode the filename with the accents in the source code instead of reading it in the csv file.</p>
  
  <p>Any ideas of how to fix this ?</p>
  
  <p>Thank you for your help</p>