title: Reading Doubles from a Scanner in Java not working out
body: <p><strong>Edit: figured it out, misplaced a piece of code</strong></p>
  
  <p>I have a program that calculates slopes from a file. The format the file is in is like this:</p>
  
  <blockquote>
    <p>Y2 'space' Y1 'space' X2 'space' X1 'space'</p>
  </blockquote>
  
  <p>I am using a Scanner to read Strings from the file then converting them to a double or integer. The reason I am doing this is because it seems like it doesn't read doubles or integers from a text file only strings. Here is some of my code:</p>
  
  <pre><code> modelSlopes.clear();
      modelValues.clear();
      int returnVal = openFileChooser.showOpenDialog(this);
  
      if (returnVal == JFileChooser.APPROVE_OPTION) {
          File file = openFileChooser.getSelectedFile();
          try {
              Scanner fileScanner = new Scanner(new FileReader(file));
              int count = 1;
              boolean suc = true;
              while (fileScanner.hasNext()) {
                  suc = true;
                  double tmp1 = 0;
                  double tmp2 = 0;
                  double tmp3 = 0;
                  double tmp4 = 0;
                  try {
                      if(count == 1) {
                          tmp1 = Double.valueOf(fileScanner.next());
  
                      }
                      if(count == 2) {
                          tmp2 = Double.valueOf(fileScanner.next());
  
                      }
                      if(count == 3) {
                          tmp3 = Double.valueOf(fileScanner.next());
  
                      }
                      if(count == 4) {
                          tmp4 = Double.valueOf(fileScanner.next());
  
                      }
  
                  } catch (NumberFormatException e) {
  
                      try {
                          if(count == 1) {
                              tmp1 = Integer.valueOf(fileScanner.next());
                          }
                          if(count == 2) {
                              tmp2 = Integer.valueOf(fileScanner.next());
                          }
                          if(count == 3) {
                              tmp3 = Integer.valueOf(fileScanner.next());
                          }
                          if(count == 4) {
                              tmp4 = Integer.valueOf(fileScanner.next());
                          }
                      } catch(NumberFormatException e1) {
                          suc = false;
                      }
                  }
  
                  if(suc)  {
                      if(count != 4) {
                          count++;
                      }
                      if(count == 4) {
                          count = 1;
                          SlopeSolver tmpS = new SlopeSolver(Double.valueOf(tmp1), Double.valueOf(tmp2), Double.valueOf(tmp3), Double.valueOf(tmp4));
                          modelSlopes.addElement(tmpS.getSlope());
                          modelValues.addElement("Y2 - " + String.valueOf(tmp1) + "; Y1 - " + String.valueOf(tmp2) + "; X2 - " + String.valueOf(tmp3) + "; X1 - " + String.valueOf(tmp4));
  
                      }
                  }
              }
          } catch (Exception e) {
              JOptionPane.showMessageDialog(this, "Error opening or with file");
          }
      } else {
      }
  </code></pre>
  
  <p>When I do this it displays 0's for the slope and the values. I can't seem to get it to work. I am new to java, and I am pretty clueless right now. Any help would be appreciated.</p>
  
  <p>Here is the text file I am reading data from:</p>
  
  <pre><code>0.0 2.0 0.0 1.0
  </code></pre>
  
  <p>~Andrew</p>