Reading .bin files
So I have the following code:
Now, I have to write code to read those files back into variables and print them back out again. So for example, I have to have a double variable that reads in the 3.14159, an int variable that reads in the 500, and so on. How do I read .bin files in Java to be able to do this?
DataOutputStreamout = new DataOutputStream(newFileOutputStream("C:/Users/******/Desktop/data.bin"));
By turning it around:
DataInputStream in = new DataInputStream(new FileInputStream("C:/Users/******/Desktop/data.bin"));
double d = in.readDouble();
int i = in.readInt();
boolean b = in.readBoolean();
I don't know what is in a .bin file.
If you can give me the format, byte by byte of what is in the .bin file, I will try to show you how to read it.
For the file you wrote to a DataOutputStream, look at the DataInputStream class for the methods to read the data back. Obviously they must match exactly what was written out.
Yeah hey that works, thanks man. I guess what you did makes sense, I didn't know about the DataInputStream class until now, lol
Originally Posted by PhHein