I want to write the ArrayList<Double> array into the file in such a way that when I double click on the file then the file opens and the user can read the data.
I have tried the DataOutputStream & RandomAccessFile; both works fine but when I double click on the file it shows data which is not in readable form.
I tried this:
ArrayList<Double> larr=new ArrayList<Double>();
larr.add(5.66);
larr.add(7.89);
try{
FileOutputStream fos = new FileOutputStream("out.txt");
DataOutputStream dos = new DataOutputStream(fos);
for(Double d:larr)
dos.writeDouble(d);
dos.close();
} catch(Exception ex) {
ex.printStackTrace();
}
But now the case is that when I open the file out.txt by double clicking on it. It comes in non-readable form.
PrintWriter.print(double)PrintWriter.print(double)but don't you think it will print only on console as my file remains empty.