go to previous page   go to home page   go to next page        


Yes. This might happen accidentally if the data in the file just happened to correspond to those characters. But this would be very rare.

Why Binary Files are Needed

Most digital data is stored in binary files. Pure text files are somewhat rare (probably less than 2% of the data in the world). There are several reasons why binary files are used.

I. Input and output are much faster using binary data. Converting a 32-bit integer to characters takes time. Not a great deal of time, but if a file (such as an image file) contains millions of numbers the accumulated conversion time is significant. Computer games would slow to a crawl if their data were stored in character form.

II. A binary file is usually very much smaller than a text file that contains an equivalent amount of data. For image, video, and audio data this is important. Small files save storage space, can be transmitted faster, and are processed faster. IO with smaller files is faster, too, since there are fewer bytes to move. A DVD would not have room enough to store a movie if the data were stored in character format.

III. Some kinds of data can't easily be represented as characters. For example, the bytecodes of a Java class file or the machine language of an executable file. You may not usually think of this as data, but of course, it is. The Java compiler reads an input file (a source file) and writes a binary data file containing its results (the bytecode file).


Files can be compressed with a utility program like Zip. Often a text file can be compressed to less than half its original size.

Can the compressed text file be read with a FileReader stream?