Class DataOutputStream

DataOutputStream
DataOutputStream
• A data output stream lets an application write
primitive Java data types to an output stream
in a portable way. An application can then use
a data input stream to read the data back in.

DataOutputStream
java.io.DataOutputStream
public class DataOutputStream extends OutputStream
implements DataOutput

DataOutputStream
DataOutputStream constructor
• DataOutputStream(OutputStream out)
• Creates a new data output stream to write
data to the specified underlying output
stream.

DataOutputStream
writeUTF()
• Writes a string to the underlying output
stream using UTF-8 encoding in a machineindependent manner.

DataOutputStream
writeUTF()
• public final void writeUTF(String str) throws
IOException
• First, two bytes are written to the output stream
as if by the writeShort method giving the number
of bytes to follow. This value is the number of
bytes actually written out, not the length of the
string. Following the length, each character of the
string is output, in sequence, using the UTF-8
encoding for the character.
DataOutputStream
writeBoolean()
• Writes a boolean to the underlying output
stream as a 1-byte value. The value true is
written out as the value (byte)1; the
value false is written out as the value (byte)0.

DataOutputStream
writeBoolean()
syntax
public final void writeBoolean(boolean v)
throws IOException

DataOutputStream
writeInt()
• Writes an int to the underlying output stream
as four bytes, high byte first
• public final void writeInt(int v) throws
IOException

DataOutputStream
Flush()
• Flushes this data output stream. This forces
any buffered output bytes to be written out to
the stream.The flush method
of DataOutputStream calls the flush method
of its underlying output stream.
• public void flush() throws IOException

DataOutputStream
Close()
• 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.
• public void close() throws IOException

DataOutputStream

Class data outputstream

  • 1.
  • 2.
    DataOutputStream • A dataoutput stream lets an application write primitive Java data types to an output stream in a portable way. An application can then use a data input stream to read the data back in. DataOutputStream
  • 3.
    java.io.DataOutputStream public class DataOutputStreamextends OutputStream implements DataOutput DataOutputStream
  • 4.
    DataOutputStream constructor • DataOutputStream(OutputStreamout) • Creates a new data output stream to write data to the specified underlying output stream. DataOutputStream
  • 5.
    writeUTF() • Writes astring to the underlying output stream using UTF-8 encoding in a machineindependent manner. DataOutputStream
  • 6.
    writeUTF() • public finalvoid writeUTF(String str) throws IOException • First, two bytes are written to the output stream as if by the writeShort method giving the number of bytes to follow. This value is the number of bytes actually written out, not the length of the string. Following the length, each character of the string is output, in sequence, using the UTF-8 encoding for the character. DataOutputStream
  • 7.
    writeBoolean() • Writes aboolean to the underlying output stream as a 1-byte value. The value true is written out as the value (byte)1; the value false is written out as the value (byte)0. DataOutputStream
  • 8.
    writeBoolean() syntax public final voidwriteBoolean(boolean v) throws IOException DataOutputStream
  • 9.
    writeInt() • Writes anint to the underlying output stream as four bytes, high byte first • public final void writeInt(int v) throws IOException DataOutputStream
  • 10.
    Flush() • Flushes thisdata output stream. This forces any buffered output bytes to be written out to the stream.The flush method of DataOutputStream calls the flush method of its underlying output stream. • public void flush() throws IOException DataOutputStream
  • 11.
    Close() • Closes thisoutput 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. • public void close() throws IOException DataOutputStream