Next: The DataOutputStream class. Up: Binary files. Previous: Binary vs text files.
Textbook: Section 14.5
The DataInputStream class is layed on top of the FileInputStream class (actually, it's layered on top of the InputStream class, of which FileInputStream is a subclass).
the DataInputStream would read this as the binary number 1000000100(2), which is 1028(10).00 00 02 04
The UTF format is a standard for representing strings in a file, engineered to make it easy to recover a string from a file, regardless of what computer you're using. It begins with two bytes saying in binary how many bytes long the remainder of the string representation is, followed by the characters of the string represented in UTF-8 format (which basically represents ASCII characters as is, with non-ASCII Unicode characters handled in a more complex way). For example, the string ``CAB'' would be represented by the following five bytes (represented here in hexadecimal).
00 03 43 41 42
Next: The DataOutputStream class. Up: Binary files. Previous: Binary vs text files.