title: Cannot convert String to int in Java
body: <p>In my program I need to convert a String to Int.</p>
  
  <pre><code>    String str = new String(request.getData());
  
      String [] setting = str.split(" ");        
      String bs = setting[1];
  </code></pre>
  
  <p>The value of bs is 1024, I use <code>System.out.println</code> to test it, and it displays on the screen with "1024".</p>
  
  <p>But when I use </p>
  
  <pre><code>    int blockSize = Integer.parseInt(bs); 
  </code></pre>
  
  <p>it will return an exception point to the line of <code>Integer.parseInt</code> :</p>
  
  <pre><code>Exception in thread "main" java.lang.NumberFormatException: For input string: "1024"
    at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)
    at java.lang.Integer.parseInt(Integer.java:458)
    at java.lang.Integer.valueOf(Integer.java:554)
  </code></pre>
  
  <p>Can someone help me to solve it? Thanks.</p>