title: Why does the Integer.parseInt throw NumberFormatException on input that seems valid?
body: <p>I'm doing a simple exercise from a book and I'm a little bit confused with how the java function parseInt works. I have read a line from an input file, used the StringTokenizer to split it and now I want to parse each part as an integer.</p>
  
  <p>I have checked in the watch window that the input of the parseInt function is indeed a string which seems a valid integer (e.g. "35"). However, when I try to use the <code>str.charAt</code> function on my variable <code>str</code> holding the value "35", I get strange results :</p>
  
  <pre><code>str.charAt(0) == ""
  str.charAt(1) == "3"
  str.charAt(2) == ""
  str.charAt(3) == "5"
  </code></pre>
  
  <p>This seems to be a problem probably somehow related to the encoding, so I have tried to fix it using this way of reading the file :</p>
  
  <pre><code>InputStreamReader reader = new InputStreamReader(new FileInputStream(inputfile), "UTF-8");
  </code></pre>
  
  <p>(I have explicitly saved the file using UTF-8 encoding in my editor), but this didn't help. Any ideas what could be the problem and how to fix it ?</p>
  
  <p>EDIT : My sample </p>
  
  <pre><code>        InputStreamReader reader = new InputStreamReader(new FileInputStream(inputfile), "UTF-8");
          BufferedReader bfreader = new BufferedReader(reader);
  
          line = bfreader.readLine();
          while (line !=null)
          {
                  String[] valueStrings = line.split(" ");
                  String hole = valueStrings[0]; 
  
                  int[] values = new int[4];
                  for (int i = 0; i &lt;values.length; i++){
  
                      String nr = valueStrings[i+1].trim(); 
                      values [i] = Integer.parseInt(nr);
                  }
  
                  // it breaks at the parseInt here, the rest is not even executed...
  
           }
  </code></pre>