@Override public void writeBinary(DataOutput out) throws IOException { final int rows = this.getRowDimension(); final int cols = this.getColumnDimension(); final double[][] data = this.getArray(); out.writeInt(rows); out.writeInt(cols); for (int r=0; r<rows; r++) for (int c=0; c<cols; c++) out.writeDouble(data[r][c]); } }
@Override public void readBinary(DataInput in) throws IOException { final int rows = in.readInt(); final int cols = in.readInt(); double[][] data = new double[rows][cols]; for (int r=0; r<rows; r++) for (int c=0; c<cols; c++) data[r][c] = in.readDouble(); setData(rows, cols, data); }
@Override public void writeASCII(PrintWriter out) throws IOException { super.writeASCII(out); for (String s : index) out.println(s); }
@Override public void writeBinary(DataOutput out) throws IOException { super.writeBinary(out); for (String s : index) out.writeUTF(s); }
@Override public void readASCII(Scanner in) throws IOException { super.readASCII(in); index = new String[this.getRowDimension()]; for (int i=0; i<index.length; i++) index[i] = in.nextLine(); }
@Override public void readBinary(DataInput in) throws IOException { super.readBinary(in); index = new String[this.getRowDimension()]; for (int i=0; i<index.length; i++) index[i] = in.readUTF(); }
@Override public void writeASCII(PrintWriter out) throws IOException { final int rows = this.getRowDimension(); final int cols = this.getColumnDimension(); final double[][] data = this.getArray(); out.print(rows + " " + cols); out.println(); for (int r=0; r<rows; r++) { for (int c=0; c<cols; c++) { out.print(data[r][c] + " "); } out.println(); } }
@Override public void readASCII(Scanner in) throws IOException { final int rows = in.nextInt(); final int cols = in.nextInt(); double[][] data = new double[rows][cols]; for (int r=0; r<rows; r++) for (int c=0; c<cols; c++) data[r][c] = in.nextDouble(); setData(rows, cols, data); }