title: NumberFormatException for String that appears to be a number
body: <p>I have a little problem with one JAVA program. 
  I am trying to do a InsertionSort algorithm, but it seems to be the problem with converting String that program gets via stdin. It seems like program is working with few numbers, but it doesn't work with these numbers:
  <a href="https://dl.dropboxusercontent.com/u/57540732/numbers.txt">https://dl.dropboxusercontent.com/u/57540732/numbers.txt</a></p>
  
  <p>This is my algorithm:</p>
  
  <pre><code>public class Sort {
  
      private static ArrayList&lt;String&gt; insertionSort(ArrayList&lt;String&gt; arr) {
          for (int i = 1; i &lt; arr.size(); i++) {
              int valueToSort = Integer.parseInt(arr.get(i).trim());
              int j = i;
              while (j &gt; 0 &amp;&amp; Integer.parseInt(arr.get(j - 1).trim()) &gt; valueToSort) {
                  arr.set(j, arr.get(j-1));
                  j--;
              }
              arr.set(j, Integer.toString(valueToSort));
          }
          return arr;
      }
  
      public static void main(String[] args) {
          Scanner sc = new Scanner(System.in);
          ArrayList&lt;String&gt; al;
          String inputNumbers = sc.nextLine();
          String[] xs = inputNumbers.split(" ");
          al = new ArrayList&lt;String&gt;(Arrays.asList(xs));
          al = insertionSort(al);
          for (int i = 0; i&lt;al.size(); i++) {
              System.out.print(al.get(i) + " ");
          }
      }
  }
  </code></pre>
  
  <p>It works with few numbers, but not with that files I provided to you. I get following exception: </p>
  
  <pre><code>Exception in thread "main" java.lang.NumberFormatException: For input string: "﻿4531"
      at java.lang.NumberFormatException.forInputString(NumberFormatException.java:65)
      at java.lang.Integer.parseInt(Integer.java:580)
      at java.lang.Integer.parseInt(Integer.java:615)
      at Sort.insertionSort(Sort.java:10)
      at Sort.main(Sort.java:25)
  </code></pre>
  
  <p>I don't know why I get this exception, because input string is a number (4531). Any suggestions?
  I can't copy and paste al of the numbers from file to terminal, so I am using this command:</p>
  
  <pre><code>javac Sort.java
  java Sort &lt; numbers.txt
  </code></pre>