java.lang.Object | |||
↳ | java.io.OutputStream | ||
↳ | java.io.FilterOutputStream | ||
↳ | java.io.DataOutputStream |
Wraps an existing OutputStream
and writes typed data to it.
Typically, this stream can be read in by DataInputStream. Types that can be
written include byte, 16-bit short, 32-bit int, 32-bit float, 64-bit long,
64-bit double, byte strings, and MUTF-8
encoded strings.
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
written | The number of bytes written out so far. |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class
java.io.FilterOutputStream
|
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Constructs a new
DataOutputStream on the OutputStream
out . |
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Flushes this stream to ensure all pending data is sent out to the target
stream.
| |||||||||||
Returns the total number of bytes written to the target stream so far.
| |||||||||||
Writes a byte to the target stream.
| |||||||||||
Writes
count bytes from the byte array buffer starting at
offset to the target stream. | |||||||||||
Writes a boolean to the target stream.
| |||||||||||
Writes an 8-bit byte to the target stream.
| |||||||||||
Writes the low order bytes from a string to the target stream.
| |||||||||||
Writes a 16-bit character to the target stream.
| |||||||||||
Writes the 16-bit characters contained in
str to the target
stream. | |||||||||||
Writes a 64-bit double to the target stream.
| |||||||||||
Writes a 32-bit float to the target stream.
| |||||||||||
Writes a 32-bit int to the target stream.
| |||||||||||
Writes a 64-bit long to the target stream.
| |||||||||||
Writes the specified 16-bit short to the target stream.
| |||||||||||
Writes the specified encoded in
modified UTF-8 to this
stream. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
From class java.io.FilterOutputStream
| |||||||||||
From class java.io.OutputStream
| |||||||||||
From class java.lang.Object
| |||||||||||
From interface java.io.Closeable
| |||||||||||
From interface java.io.DataOutput
| |||||||||||
From interface java.io.Flushable
|
Constructs a new DataOutputStream
on the OutputStream
out
. Note that data written by this stream is not in a human
readable form but can be reconstructed by using a DataInputStream
on the resulting output.
out | the target stream for writing. |
---|
Flushes this stream to ensure all pending data is sent out to the target stream. This implementation then also flushes the target stream.
IOException | if an error occurs attempting to flush this stream. |
---|
Returns the total number of bytes written to the target stream so far.
Writes a byte to the target stream. Only the least significant byte of
the integer oneByte
is written.
oneByte | the byte to write to the target stream. |
---|
IOException | if an error occurs while writing to the target stream. |
---|
Writes count
bytes from the byte array buffer
starting at
offset
to the target stream.
buffer | the buffer to write to the target stream. |
---|---|
offset | the index of the first byte in buffer to write. |
count | the number of bytes from the buffer to write. |
IOException | if an error occurs while writing to the target stream. |
---|---|
NullPointerException | if buffer is null . |
Writes a boolean to the target stream.
val | the boolean value to write to the target stream. |
---|
IOException | if an error occurs while writing to the target stream. |
---|
Writes an 8-bit byte to the target stream. Only the least significant
byte of the integer val
is written.
val | the byte value to write to the target stream. |
---|
IOException | if an error occurs while writing to the target stream. |
---|
Writes the low order bytes from a string to the target stream.
str | the string containing the bytes to write to the target stream. |
---|
IOException | if an error occurs while writing to the target stream. |
---|
Writes a 16-bit character to the target stream. Only the two lower bytes
of the integer val
are written, with the higher one written
first. This corresponds to the Unicode value of val
.
val | the character to write to the target stream |
---|
IOException | if an error occurs while writing to the target stream. |
---|
Writes the 16-bit characters contained in str
to the target
stream.
str | the string that contains the characters to write to this stream. |
---|
IOException | if an error occurs while writing to the target stream. |
---|
Writes a 64-bit double to the target stream. The resulting output is the eight bytes resulting from calling Double.doubleToLongBits().
val | the double to write to the target stream. |
---|
IOException | if an error occurs while writing to the target stream. |
---|
Writes a 32-bit float to the target stream. The resulting output is the four bytes resulting from calling Float.floatToIntBits().
val | the float to write to the target stream. |
---|
IOException | if an error occurs while writing to the target stream. |
---|
Writes a 32-bit int to the target stream. The resulting output is the
four bytes, highest order first, of val
.
val | the int to write to the target stream. |
---|
IOException | if an error occurs while writing to the target stream. |
---|
Writes a 64-bit long to the target stream. The resulting output is the
eight bytes, highest order first, of val
.
val | the long to write to the target stream. |
---|
IOException | if an error occurs while writing to the target stream. |
---|
Writes the specified 16-bit short to the target stream. Only the lower
two bytes of the integer val
are written, with the higher one
written first.
val | the short to write to the target stream. |
---|
IOException | if an error occurs while writing to the target stream. |
---|
Writes the specified encoded in modified UTF-8
to this
stream.
str | the string to write to the target stream encoded in
modified UTF-8 . |
---|
IOException | if an error occurs while writing to the target stream. |
---|---|
UTFDataFormatException | if the encoded string is longer than 65535 bytes. |