Example two: Reading a CSV-file: A table of Doubles (Matrix)

    @Test
    public final void testReadAll01() throws IOException {

        /**
         * colA colB colC rowA 0.0 0.1 0.2 rowB 1.0 1.1 1.2
         */

        // A string that contains a table (tab delimited)
        final String tableString = "rowIDs\tcolA\tcolB\tcolC" + UtilIO.NEW_LINE_STRING
                + "rowA\t0.0\t0.1\t0.2" + UtilIO.NEW_LINE_STRING + "rowB\t1.0\t1.1\t1.2";

        // A Reader to read the table
        final StringReader stringReader = new StringReader(tableString);

        // A TableReader to parse the file
        // First argument is the Reader (File or Stream would also work)
        // Second argument is if column headers are present
        // Third argument is if row headers are present
        // Forth argument is column-delimiter (in this case tab)
        final ReaderTableDouble tableReader = new ReaderTableDouble(stringReader, true, true, "\t");

        // Read the table at once
        final TableDouble table = tableReader.readTableAtOnce();

        // Close the reader
        tableReader.close();

        // table does have row headers
        assertEquals(2, table.getRowIdentifier().size());

        // table does have column headers
        assertEquals(3, table.getColumnIdentifier().size());

        assertArrayEquals(new Double[] { 0.0, 1.0 }, table.getColumn("colA").toArray());
        assertArrayEquals(new Double[] { 0.1, 1.1 }, table.getColumn("colB").toArray());
        assertArrayEquals(new Double[] { 0.2, 1.2 }, table.getColumn("colC").toArray());

        assertArrayEquals(new Double[] { 0.0, 0.1, 0.2 }, table.getRow("rowA").toArray());
        assertArrayEquals(new Double[] { 1.0, 1.1, 1.2 }, table.getRow("rowB").toArray());

    }