Here you can find the source of saveDoubleMatrixFromBinary(DataInputStream reader, int rows, int cols, PrintStream out)
public static void saveDoubleMatrixFromBinary(DataInputStream reader, int rows, int cols, PrintStream out)
//package com.java2s; //License from project: Open Source License import java.io.DataInputStream; import java.io.EOFException; import java.io.IOException; import java.io.PrintStream; public class Main { public static void saveDoubleMatrixFromBinary(DataInputStream reader, int rows, int cols, PrintStream out) { out.println(rows + " " + cols); for (int i = 0; i < rows; i++) { double[] row = readDoubleArrayFromFileBinary(reader, cols); for (int j = 0; j < cols; j++) { out.print(row[j]);//from w w w . jav a2s . c o m if (j != cols - 1) { out.print(" "); } } out.println(); } } public static double[] readDoubleArrayFromFileBinary(DataInputStream storeReader, int dimensions) { double[] ret = new double[dimensions]; for (int i = 0; i < dimensions; i++) { try { ret[i] = storeReader.readDouble(); } catch (EOFException e) { return null; } catch (IOException e) { throw new RuntimeException(e); } } return ret; } }