Writing data array to the file is simple as shown in the code snippet below.
try {
// Create an output stream to the file.
FileOutputStream file_output = new FileOutputStream (file);
// Wrap the FileOutputStream with a DataOutputStream
DataOutputStream data_out = new DataOutputStream (file_output);
// Write the data to the file in an integer/double pair
for (int i=0; i < i_data.length; i++) {
data_out.writeInt (i_data[i]);
data_out.writeDouble (d_data[i]);
}
// Close file when finished with it..
file_output.close ();
}
catch (IOException e) {
System.out.println ("IO exception = " + e );
}