So I have two files, a binary file that I have read into a byte array, and a text file that I have read into an ArrayList of Strings. Now lets assume my ArrayList has the values "char", "int", "double" and serves as the schema for reading my binary file.
That means for the first two bytes in the byte array I want to interpret as a char, the next four as an int, and the next 8 as a double, and this will repeat itself until the file is over.
I've implemented reading in all the data, but I can't figure out a good way to properly interpret the binary data according to the schema file. Is there a good way to do this?
IE (psuedocode) using PrintStream out = new PrintStream (new OutputStream(byteArray))
out.writeChar()
out.writeInt()
out.writeDouble()
Where the Stream works through the byteArray for me? (As opposed to me saying out.writeChar(byteArray[2])?
I have figurd out all the logic of mapping the schema to the proper action, but I am having trouble properly converting the data. Any thoughts?
I want to write this information to either the console (or a file).