aspose file tools
The moose likes Beginning Java and the fly likes Loading Binary files Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Reply Bookmark "Loading Binary files" Watch "Loading Binary files" New topic
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.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Loading Binary files
 
Similar Threads
Problems installing J2EE on Solaris for Intel
JCE and binary private keys
Little help with reading files
"R" letter is going to give some difficult times during the promo
How to work with Binary Files?