to print the text file in 2d matrix of same dimension given in file using java
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/5830453/how-to-print-2d-array-from-txt-file-in-java">How to print 2D Array from .txt file in Java</a>  </p>
</blockquote>



<p>text file is:</p>

<pre><code>8.00 28.00  
18.00 28.00 
8.00 23.00  
12.00 20.00 
15.00 30.00 
... etc (many more lines)
</code></pre>

<p>i am reached upto:</p>

<pre><code>public class Asgn2backup {
    public static double[][] matrix;

    public static void main(final String[] args) throws IOException {
        System.out.print("Enter the name of the file: ");
        final String fileName = readInput();

        final BufferedReader br = new BufferedReader(
             new FileReader(fileName + ".txt"));
        String line;
        int order = 0;

        int rowIndex = 0;
        int counter = 0;
        while ((line = br.readLine()) != null) {
            counter++;
            if (counter == 1) {
                order = Integer.parseInt(line);
                matrix = new double[order][order];
                System.out.println("order: " + order);
            }

            if (counter == 2) {

                final String source = line;
                System.out.println("source: " + source);
            }

            if (counter != 2 &amp;&amp; counter != 1) {
                order = Integer.parseInt(line);
                matrix = new double[order][order];
                System.out.println("order: " + order);
                final StringTokenizer theLine = 
                    new StringTokenizer(line, ", ");
                int colIndex = 0;
                while (theLine.hasMoreTokens()) {
                    final String st = theLine.nextToken();// .trim();
                    matrix[rowIndex][colIndex] = Double.parseDouble(st);
                    colIndex = colIndex + 1;
                }
                rowIndex = rowIndex + 1;
            }

        }

        for (int x = 0; x &lt; matrix.length - 1; x++) {
            for (int p = 0; p &lt; matrix.length - 1; p++) {
                System.out.print(matrix[x][p] + " ");
            }
        }

        br.close();
    }

    private static String readInput() {
        try {
            final BufferedReader in = new BufferedReader(
                new InputStreamReader(System.in));
            return in.readLine();
        } catch (final IOException e) {
        }
        return "";
    }

}
</code></pre>

<p>but it gives numberformatexception runtime error.
give me complete solution.
pls help me.</p>
