Next: The DataInputStream class. Up: Binary files. Previous: None.


Binary vs text files

A text file is a file that is properly understood as a sequence of character data (represented using ASCII, Unicode, or some other standard), separated into lines. Typically, when a text file is displayed as a sequence of characters, it is easily human-readable (though perhaps not understandable - for example, the Breakout level file was a text file, but it certainly wouldn't be understandable without some sort of decoder telling which numbers represented what).

A binary file is anything else. A binary file will include some data that is not written using a character-encoding standard - typically, some number would be represented using binary within the file, instead of using the character representation of its various digits (in some base).

Whether you use a binary file or a text file for storing information depends on basically two questions.

For the Breakout lab, file size/speed was unimportant - it was a small file anyway, and you only had to read it once. But portability was a major concern, since each student had to implement the file format themselves. Thus we used a text file.


Next: The DataInputStream class. Up: Binary files. Previous: None.