title: java.lang.numberformatexception invalid int ""
body: <p>Trying to write code that will read a number from a file as a string and then convert it to an int. The code crashes when trying to convert from string to int for some reason.</p>
  
  <p>Code executes in the onCreate function of an Android activity.
  Code runs fine when the sample.txt is empty but crashes and returns the following error when any number is in the first line of the sample.txt file:</p>
  
  <p>" java.lang.numberformatexception invalid int "" "</p>
  
  <pre><code>public static int LastScore;
  public File sdcard = Environment.getExternalStorageDirectory();
  public File file = new File(sdcard,"sample.txt");
  
  
      try{
          BufferedReader br = new BufferedReader(new FileReader(file));
              String line = null;
              line = br.readLine();
           if(line!=null){
                  LastScore = Integer.parseInt(line);
                         }
  
      }catch (IOException e){
          System.err.println(e);
      }
  </code></pre>
  
  <p>sample.txt currently contains the number '2' on its first line.</p>
  
  <p>Any help would be appreciated.</p>
  
  <p>EDIT: Code now working. Added adjustments to original code.
  Thanks for the help.</p>