Writing binary files in java
This might happen accidentally if the data in the file just happened to correspond to those characters. But this would be very rare. Most digital data is stored in binary files. There are several reasons why binary files are used. Input and output are much faster using binary data.
Converting a 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. 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 writing binary files in java faster. A DVD would not have room enough to store a movie if the data were stored in character format. 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. 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 writing binary files in java scientific measurements. But these special occasions can use hex dumps or other specialized programs. Files can be compressed with a utility program like Zip. Often a text file can be compressed to less than writing binary files in java its original size.
Why Binary Files are Needed Most digital data is stored in binary files. Can the compressed text file be read with a FileReader stream?