Package java.io

Class DataOutputStream

All Implemented Interfaces:
Closeable, DataOutput, Flushable, AutoCloseable

public class DataOutputStream
extends FilterOutputStream
implements DataOutput
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
  • Field Summary

    Fields 
    Modifier and Type Field Description
    protected int written
    The number of bytes written out so far.

    Fields inherited from class java.io.FilterOutputStream

    out
  • Constructor Summary

    Constructors 
    Constructor Description
    DataOutputStream​(OutputStream out)
    Constructs a new DataOutputStream on the OutputStream out.
  • Method Summary

    Modifier and Type Method Description
    void flush()
    Flushes this stream to ensure all pending data is sent out to the target stream.
    int size()
    Returns the total number of bytes written to the target stream so far.
    void write​(byte[] buffer, int offset, int count)
    Writes count bytes from the byte array buffer starting at offset to the target stream.
    void write​(int oneByte)
    Writes a byte to the target stream.
    void writeBoolean​(boolean val)
    Writes a boolean to the target stream.
    void writeByte​(int val)
    Writes an 8-bit byte to the target stream.
    void writeBytes​(String str)
    Writes the low order 8-bit bytes from the specified string.
    void writeChar​(int val)
    Writes the specified 16-bit character in big-endian order.
    void writeChars​(String str)
    Writes the 16-bit characters contained in str in big-endian order.
    void writeDouble​(double val)
    Writes the specified 64-bit double in big-endian order.
    void writeFloat​(float val)
    Writes the specified 32-bit float in big-endian order.
    void writeInt​(int val)
    Writes the specified 32-bit int in big-endian order.
    void writeLong​(long val)
    Writes the specified 64-bit long in big-endian order.
    void writeShort​(int val)
    Writes the specified 16-bit short in big-endian order.
    void writeUTF​(String str)
    Writes the specified string encoded in modified UTF-8.

    Methods inherited from class java.io.FilterOutputStream

    close

    Methods inherited from class java.io.OutputStream

    write

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface java.io.DataOutput

    write