Chapter 7. Data Streams
streams read and write strings, integers, floating-point numbers, and
other data that’s commonly presented at a higher level than
mere bytes. The
java.io.DataOutputStream classes read and write
the primitive Java data types (
double, etc.) and strings
in a particular, well-defined, platform-independent format. Since
DataOutputStream use the same formats,
they’re complementary. What a data output stream writes, a data
input stream can read. These classes are especially useful when you
need to move data between platforms that may use different native
formats for integers or floating-point numbers.
The Data Stream Classes
classes are subclasses of
FilterOutputStream , respectively.
public class DataInputStream extends FilterInputStream implements DataInput public class DataOutputStream extends FilterOutputStream implements DataOutput
They have all the usual methods
you’ve come to associate with input and output stream classes,
(Data input streams support marking if, and only if, their underlying
input stream supports marking.) However, the real purpose of
DataOutputStream is not to read and write raw bytes using the standard input and output stream methods. It’s to read and interpret multibyte data like ...