| Author |
Loading Binary files
|
Bob Zoloman
Ranch Hand
Joined: Jul 02, 2006
Posts: 72
|
|
|
If I load a binary file, would that file display only 1's and 0's, no matter what kind of file I load(image, text file, jpg, etc)? When I load a file as a binary file, which read method should I use? At the moment I'm using readByte, but I'm not sure if thats the right one to use. Thanks in advance.
|
 |
Manuel Moons
Ranch Hand
Joined: Mar 05, 2002
Posts: 229
|
|
A binary file means that it is not a file that can be (simply) read by looking at the contents. It means that it is formatted in such a way that is specific for a computer (program) to understand it. It does not mean that if you open it in a simple texteditor that it contains only one's and zero's. Remember, 8 bits is 1 byte. This means that the texteditor will show you the characters that represent the byte. You can read a binary file with whatever method you would like. InputStreams deal with bytes however. So if you want to printout the binary content of a file you will have to translate the byte to a binary number. eg. byte value = 4 --> binary value = 0100 [ September 08, 2006: Message edited by: Manuel Moons ]
|
 |
Srinivas Kalvala
Ranch Hand
Joined: Oct 20, 2005
Posts: 257
|
|
Hello, in java.io, Streams are good to read the bytes and Readers are good to read teh characters. But it is upto your program how to read and manage the bits.
|
 |
 |
|
|
subject: Loading Binary files
|
|
|