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

Answer:

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 Used

Most digital data is stored in binary files (not text.) 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. I/O 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).

IV. And almost never is a human going to look at the individual data samples, so there is no reason to make it human-readable. For example, humans look at the entire picture of a GIF file, and have little interest in looking at the individual pixels as numbers. Sometimes a programmer or scientist needs to do this, perhaps for debugging or scientific measurements. But these special occasions can use hex dumps or other specialized programs.


QUESTION 6:

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?


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