Convert string to doubles in a .txt file?
<p>I have a .txt file of numbers that are formatted like the following:</p>

<p><code>1.2 2.3 3.4 4.5
2.0 3.0 4.0 5.0
6.0 7.0 8.0 9.0</code></p>

<p>I'm trying to use a scanner to take each line as a string, convert each number to a double and then add them together to print to a new .txt file. 
My error message looks like this:</p>

<blockquote>
  <p>Exception in thread "main" java.lang.NumberFormatException: For input
  string: "1.2 2.3 3.4 4.5"     at
  sun.misc.FloatingDecimal.readJavaFormatString(FloatingDecimal.java:2043)
    at sun.misc.FloatingDecimal.parseDouble(FloatingDecimal.java:110)   at
  java.lang.Double.parseDouble(Double.java:538)     at
  scanstrings.ScanStrings.parseDouble(ScanStrings.java:51)  at
  scanstrings.ScanStrings.main(ScanStrings.java:33)</p>
</blockquote>

<p>I was trying to use a split to separate each number so that they could be converted to doubles, but no matter what I do nothing seems to work, and I've found ways to split using spaces and periods but each way I try returns the same error message. </p>

<p>My code basically looks like this right now (I'm just starting so I'm sorry if it's just bad, I've also been messing with this for a while so some parts might just not make sense</p>

<pre><code> //Construct Scanner object for the input file 
    Scanner input = new Scanner (new File("one.txt"));

    //Construct Scanner object for the output file
    PrintWriter output = new PrintWriter("result.txt");

    //Read lines from the input file

    while(input.hasNextLine()){
        String line = input.nextLine();

        String[] conv = line.split("\\s+");
        String dub1 = conv[0];
        String dub2 = conv[1];
        String dub3 = conv[2];
        String dub4 = conv[3];


        //convert to double
        double dub = parseDouble(line);

        //compute sum
        double total = 0;
        if (dub != 0) //protect against division by zero
        {
            total += dub;
        }
        System.out.printf("\n", dub, total);
    }

    input.close();
    output.close();     
}

public static double parseDouble(String conv) throws NumberFormatException{
    int i = 0;
    while (!Character.isDigit(conv.charAt(i))) { i++; }
    return Double.parseDouble(conv.substring(i).trim());
}
</code></pre>