Does anyone know of a good resource for working with binary files in Java?
Most of the resources, including texts, seem to be of the opinion that binary file operations are abstracted away and completely portable. I have a hard time buying that. I can believe that binary files created and read by Java programs are portable across platforms because the underlying JVM makes them so, but I don't buy that this applies in general. For instance, most binary file formats, such as BMP and WAV, explicitly specify the endianness of values stored in them. Unless you are using a Java library class to access them (so that the library class knows this information), there is no way for the JVM to know how to deal with the endianness of an arbitrary binary file format.
I've seen some disjointed references on how to get at the endianness of the underlying hardware, but that is irrelevant (unless the Java JVM implementation makes it relevant).
What I'm looking for is a class that reads data from a file into a variable (or memory buffer) and vice verse in the same order that it is in the file.
I can certainly play around and figure out how it works on my machine, but I want a means that is portable to other platforms.
Most of the resources, including texts, seem to be of the opinion that binary file operations are abstracted away and completely portable. I have a hard time buying that. I can believe that binary files created and read by Java programs are portable across platforms because the underlying JVM makes them so, but I don't buy that this applies in general. For instance, most binary file formats, such as BMP and WAV, explicitly specify the endianness of values stored in them. Unless you are using a Java library class to access them (so that the library class knows this information), there is no way for the JVM to know how to deal with the endianness of an arbitrary binary file format.
I've seen some disjointed references on how to get at the endianness of the underlying hardware, but that is irrelevant (unless the Java JVM implementation makes it relevant).
What I'm looking for is a class that reads data from a file into a variable (or memory buffer) and vice verse in the same order that it is in the file.
I can certainly play around and figure out how it works on my machine, but I want a means that is portable to other platforms.