Byte-Based and Character-Based Streams
File streams can be used to input and output data as bytes or characters.
• Byte-based streams output and input data in its binary format—a char
is two bytes, an int
is four bytes, a double
is eight bytes, etc.
• Character-based streams output and input data as a sequence of characters in which every character is two bytes—the number of bytes for a given value depends on the number of characters in that value. For example, the value 2000000000
requires 20 bytes (10 characters at two bytes per character) but the value 7
requires only two bytes (1 character at two bytes per character).
Files created using byte-based streams are referred to as binary files, while files created using character-based streams ...
Get Java™ How To Program (Early Objects), Tenth Edition now with the O’Reilly learning platform.
O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.