    All Packages    This Package    Previous    Next

# Class java.io.DataOutputStream

    java.lang.Object
       |
       +----java.io.OutputStream
               |
               +----java.io.FilterOutputStream
                       |
                       +----java.io.DataOutputStream

public class DataOutputStream
extends FilterOutputStream

This class lets you write primitive Java data types to a stream in a portable way. The data can be converted back using a DataInputStream.

##

written
  The number of bytes written so far.

##

DataOutputStream(OutputStream)
  Creates a new DataOutputStream

##

align(int)
  Aligns.
flush()
  Flushes the stream.
size()
  Returns number of bytes written.
write(int)
  Writes a byte.
write(byte[], int, int)
  Writes a sub array of bytes.
writeBoolean(boolean)
  Writes a boolean.
writeByte(int)
  Writes an 8 bit byte.
writeBytes(String)
  Writes a string as a sequence of bytes.
writeChar(int)
  Writes a 16 bit char.
writeChars(String)
  Writes a string as a sequence of chars.
writeDouble(double)
  Writes a 64 bit double.
writeFloat(float)
  Writes a 32 bit float.
writeInt(int)
  Writes a 32 bit int.
writeLong(long)
  Writes a 64 bit long.
writeShort(int)
  Writes a 16 bit short.
writeUTF(String)
  Writes string in UTF format.

##

written

      protected int written

  The number of bytes written so far.

##

DataOutputStream

      public DataOutputStream(OutputStream out)

  Creates a new DataOutputStream
  Parameters:
    out - the output stream

##

write

      public synchronized void write(int b)

  Writes a byte. Will block until the byte is actually written.
  Throws: IOException
    i/o error occurred
  Overrides:
    write in class FilterOutputStream

write

      public synchronized void write(byte b[],
                                     int off,
                                     int len)

  Writes a sub array of bytes. To be efficient it should be overridden in a subclass.
  Parameters:
    b - the data to be written
    off - the start offset in the data
    len - the number of bytes that are written
  Throws: IOException
    i/o error occurred
  Overrides:
    write in class FilterOutputStream

flush

      public void flush()

  Flushes the stream. This will write any buffered output bytes.
  Throws: IOException
    i/o error occurred
  Overrides:
    flush in class FilterOutputStream

writeBoolean

      public final void writeBoolean(boolean v)

  Writes a boolean.

writeByte

      public final void writeByte(int v)

  Writes an 8 bit byte.

writeShort

      public final void writeShort(int v)

  Writes a 16 bit short.

writeChar

      public final void writeChar(int v)

  Writes a 16 bit char.

writeInt

      public final void writeInt(int v)

  Writes a 32 bit int.

writeLong

      public final void writeLong(long v)

  Writes a 64 bit long.

writeFloat

      public final void writeFloat(float v)

  Writes a 32 bit float.

writeDouble

      public final void writeDouble(double v)

  Writes a 64 bit double.

writeBytes

      public final void writeBytes(String s)

  Writes a string as a sequence of bytes.

writeChars

      public final void writeChars(String s)

  Writes a string as a sequence of chars.

writeUTF

      public final void writeUTF(String str)

  Writes string in UTF format.

size

      public final int size()

  Returns number of bytes written.
  Returns:
    the number of bytes written sofar

align

      public final void align(int n)

  Aligns. This is useful when data fields have to be aligned on a n byte boundary.
  Parameters:
    n - the number of bytes to align on

    All Packages    This Package    Previous    Next