DthingApi
Public Member Functions | Protected Attributes | List of all members
java.io.DataOutputStream Class Reference
Inheritance diagram for java.io.DataOutputStream:
java.io.FilterOutputStream java.io.DataOutput java.io.OutputStream

Public Member Functions

 DataOutputStream (OutputStream out)
 
void close () throws IOException
 
void flush () throws IOException
 
final int size ()
 
void write (byte[] buffer, int offset, int count) throws IOException
 
void write (int oneByte) throws IOException
 
final void writeBoolean (boolean val) throws IOException
 
final void writeByte (int val) throws IOException
 
final void writeBytes (String str) throws IOException
 
final void writeChar (int val) throws IOException
 
final void writeChars (String str) throws IOException
 
final void writeDouble (double val) throws IOException
 
final void writeFloat (float val) throws IOException
 
final void writeInt (int val) throws IOException
 
final void writeLong (long val) throws IOException
 
final void writeShort (int val) throws IOException
 
final void writeUTF (String str) throws IOException
 
- Public Member Functions inherited from java.io.FilterOutputStream
 FilterOutputStream (OutputStream out)
 
void close () throws IOException
 
void flush () throws IOException
 
void write (byte[] buffer, int offset, int length) throws IOException
 
void write (int oneByte) throws IOException
 
- Public Member Functions inherited from java.io.OutputStream
 OutputStream ()
 
void close () throws IOException
 
void flush () throws IOException
 
void write (byte[] buffer) throws IOException
 
void write (byte[] buffer, int offset, int count) throws IOException
 
abstract void write (int oneByte) throws IOException
 
- Public Member Functions inherited from java.io.DataOutput
abstract void write (byte[] buffer) throws IOException
 

Protected Attributes

int written
 
- Protected Attributes inherited from java.io.FilterOutputStream
OutputStream out
 

Detailed Description

Wraps an existing OutputStream and writes big-endian 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.

See also
DataInputStream

Constructor & Destructor Documentation

◆ DataOutputStream()

java.io.DataOutputStream.DataOutputStream ( OutputStream  out)
inline

Constructs a new

on the

. 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.

Parameters
outthe target stream for writing.

Member Function Documentation

◆ close()

void java.io.DataOutputStream.close ( ) throws IOException
inline

Closes this output stream and releases any system resources associated with the stream.

The close method calls its flush method, and then calls the close method of its underlying output stream.

Exceptions
IOExceptionif an I/O error occurs.

◆ flush()

void java.io.DataOutputStream.flush ( ) throws IOException
inline

Flushes this stream to ensure all pending data is sent out to the target stream. This implementation then also flushes the target stream.

Exceptions
IOExceptionif an error occurs attempting to flush this stream.

◆ size()

final int java.io.DataOutputStream.size ( )
inline

Returns the total number of bytes written to the target stream so far.

Returns
the number of bytes written to the target stream.

◆ write() [1/2]

void java.io.DataOutputStream.write ( byte []  buffer,
int  offset,
int  count 
) throws IOException
inline

Writes

count

bytes from the byte array

buffer

starting at

offset

to the target stream.

Parameters
bufferthe buffer to write to the target stream.
offsetthe index of the first byte in
buffer
to write.
countthe number of bytes from the
buffer
to write.
Exceptions
IOExceptionif an error occurs while writing to the target stream.
NullPointerExceptionif
buffer
is
null
.

Implements java.io.DataOutput.

◆ write() [2/2]

void java.io.DataOutputStream.write ( int  oneByte) throws IOException
inline

Writes a byte to the target stream. Only the least significant byte of the integer

oneByte

is written.

Parameters
oneBytethe byte to write to the target stream.
Exceptions
IOExceptionif an error occurs while writing to the target stream.
See also
DataInputStream::readByte()

Implements java.io.DataOutput.

◆ writeBoolean()

final void java.io.DataOutputStream.writeBoolean ( boolean  val) throws IOException
inline

Writes a boolean to the target stream.

Parameters
valthe boolean value to write to the target stream.
Exceptions
IOExceptionif an error occurs while writing to the target stream.
See also
DataInputStream::readBoolean()

Implements java.io.DataOutput.

◆ writeByte()

final void java.io.DataOutputStream.writeByte ( int  val) throws IOException
inline

Writes an 8-bit byte to the target stream. Only the least significant byte of the integer

val

is written.

Parameters
valthe byte value to write to the target stream.
Exceptions
IOExceptionif an error occurs while writing to the target stream.
See also
DataInputStream::readByte()
DataInputStream::readUnsignedByte()

Implements java.io.DataOutput.

◆ writeBytes()

final void java.io.DataOutputStream.writeBytes ( String  str) throws IOException
inline

Writes the low order 8-bit bytes from the specified string.

Parameters
strthe string containing the bytes to write.
Exceptions
IOExceptionif an I/O error occurs while writing.

Implements java.io.DataOutput.

◆ writeChar()

final void java.io.DataOutputStream.writeChar ( int  val) throws IOException
inline

Writes the specified 16-bit character in big-endian order. Only the two least significant bytes of the integer

oneByte

are written.

Parameters
valthe character to write.
Exceptions
IOExceptionif an I/O error occurs while writing.
See also
DataInput::readChar()

Implements java.io.DataOutput.

◆ writeChars()

final void java.io.DataOutputStream.writeChars ( String  str) throws IOException
inline

Writes the 16-bit characters contained in

str

in big-endian order.

Parameters
strthe string that contains the characters to write.
Exceptions
IOExceptionif an I/O error occurs while writing.
See also
DataInput::readChar()

Implements java.io.DataOutput.

◆ writeDouble()

final void java.io.DataOutputStream.writeDouble ( double  val) throws IOException
inline

Writes the specified 64-bit double in big-endian order. The resulting output is the eight bytes returned by Double#doubleToLongBits(double).

Parameters
valthe double to write.
Exceptions
IOExceptionif an I/O error occurs while writing.
See also
DataInput::readDouble()

Implements java.io.DataOutput.

◆ writeFloat()

final void java.io.DataOutputStream.writeFloat ( float  val) throws IOException
inline

Writes the specified 32-bit float in big-endian order. The resulting output is the four bytes returned by Float#floatToIntBits(float).

Parameters
valthe float to write.
Exceptions
IOExceptionif an I/O error occurs while writing.
See also
DataInput::readFloat()

Implements java.io.DataOutput.

◆ writeInt()

final void java.io.DataOutputStream.writeInt ( int  val) throws IOException
inline

Writes the specified 32-bit int in big-endian order.

Parameters
valthe int to write.
Exceptions
IOExceptionif an I/O error occurs while writing.
See also
DataInput::readInt()

Implements java.io.DataOutput.

◆ writeLong()

final void java.io.DataOutputStream.writeLong ( long  val) throws IOException
inline

Writes the specified 64-bit long in big-endian order.

Parameters
valthe long to write.
Exceptions
IOExceptionif an I/O error occurs while writing.
See also
DataInput::readLong()

Implements java.io.DataOutput.

◆ writeShort()

final void java.io.DataOutputStream.writeShort ( int  val) throws IOException
inline

Writes the specified 16-bit short in big-endian order. Only the lower two bytes of

val

are written.

Parameters
valthe short to write.
Exceptions
IOExceptionif an I/O error occurs while writing.
See also
DataInput::readShort()
DataInput::readUnsignedShort()

Implements java.io.DataOutput.

◆ writeUTF()

final void java.io.DataOutputStream.writeUTF ( String  str) throws IOException
inline

Writes the specified string encoded in modified UTF-8.

Parameters
strthe string to write encoded in modified UTF-8.
Exceptions
IOExceptionif an I/O error occurs while writing.
See also
DataInput::readUTF()

Implements java.io.DataOutput.

Member Data Documentation

◆ written

int java.io.DataOutputStream.written
protected

The number of bytes written out so far.


The documentation for this class was generated from the following file: