Contents | Prev | Next | Index

22.21 The Class java.io.DataOutputStream

A data output stream provides facilities for converting data of diverse types into character sequence of specific formats that are then sent to some output stream.

public class DataOutputStream extends FilterOutputStream
		implements DataOutput {
	protected int written;
	public DataOutputStream(OutputStream out);
	public void write(int b) throws IOException;
	public void write(byte[] b, int off, int len)
		throws IOException, NullPointerException,
			IndexOutOfBoundsException;
	public void flush() throws IOException;
	public final void writeBoolean(boolean v) throws IOException;
	public final void writeByte(int v) throws IOException;
	public final void writeShort(int v) throws IOException;
	public final void writeChar(int v) throws IOException;
	public final void writeInt(int v) throws IOException;
	public final void writeLong(long v) throws IOException;
	public final void writeFloat(float v) throws IOException;
	public final void writeDouble(double v) throws IOException;
	public final void writeBytes(String s)
		throws IOException, NullPointerException;
	public final void writeChars(String s)
		throws IOException, NullPointerException;
	public final void writeUTF(String str)
		throws IOException, NullPointerException;
	public final int size();
}

22.21.1 protected int written;

This field contains the number of bytes written to the stream so far.

22.21.2 public DataOutputStream(OutputStream out)

This constructor initializes a newly created DataOutputStream by saving its argument, the output stream out, for later use. The counter written is set to zero.

22.21.3 public void write(int b) throws IOException

The byte for this operation (the low eight bits of the argument b) is written to the contained output stream. If no exception is thrown, the counter written is incremented by 1.

Implements the write method of OutputStream (§22.15.1).

22.21.4 public void write(byte[] b, int off, int len)
throws IOException, NullPointerException, IndexOutOfBoundsException

Bytes for this operation are written to the contained output stream. If no exception is thrown, the counter written is incremented by len.

Overrides the write method of OutputStream (§22.15.3).

22.21.5 public void flush() throws IOException

The contained output stream is flushed.

Overrides the flush method of OutputStream (§22.15.4).

22.21.6 public final void writeBoolean(boolean v)
throws IOException

See the general contract of the writeBoolean method of DataOutput (§22.2.4).

The byte for this operation is written to the contained output stream. If no exception is thrown, the counter written is incremented by 1.

22.21.7 public final void writeByte(int v) throws IOException

See the general contract of the writeByte method of DataOutput (§22.2.5).

The byte for this operation is written to the contained output stream. If no exception is thrown, the counter written is incremented by 1.

22.21.8 public final void writeShort(int v) throws IOException

See the general contract of the writeShort method of DataOutput (§22.2.6).

Bytes for this operation are written to the contained output stream. If no exception is thrown, the counter written is incremented by 2.

22.21.9 public final void writeChar(int v) throws IOException

See the general contract of the writeChar method of DataOutput (§22.2.7).

Bytes for this operation are written to the contained output stream. If no exception is thrown, the counter written is incremented by 2.

22.21.10 public final void writeInt(int v) throws IOException

See the general contract of the writeInt method of DataOutput (§22.2.8).

Bytes for this operation are written to the contained output stream. If no exception is thrown, the counter written is incremented by 4.

22.21.11 public final void writeLong(long v) throws IOException

See the general contract of the writeLong method of DataOutput (§22.2.9).

Bytes for this operation are written to the contained output stream. If no exception is thrown, the counter written is incremented by 8.

22.21.12 public final void writeFloat(float v) throws IOException

See the general contract of the writeFloat method of DataOutput (§22.2.10).

Bytes for this operation are written to the contained output stream. If no exception is thrown, the counter written is incremented by 4.

22.21.13 public final void writeDouble(double v) throws IOException

See the general contract of the writeDouble method of DataOutput (§22.2.11).

Bytes for this operation are written to the contained output stream. If no exception is thrown, the counter written is incremented by 8.

22.21.14 public final void writeBytes(String s)
throws IOException, NullPointerException, IndexOutOfBoundsException

See the general contract of the writeBytes method of DataOutput (§22.2.12).

Bytes for this operation are written to the contained output stream. If no exception is thrown, the counter written is incremented by the length of s.

22.21.15 public final void writeChars(String s)
throws IOException, NullPointerException, IndexOutOfBoundsException

See the general contract of the writeChars method of DataOutput (§22.2.13).

Bytes for this operation are written to the contained output stream. If no exception is thrown, the counter written is incremented by twice the length of s.

22.21.16 public final void writeUTF(String str)
throws IOException, NullPointerException, IndexOutOfBoundsException

See the general contract of the writeUTF method of DataOutput (§22.2.14).

Bytes for this operation are written to the contained output stream. If no exception is thrown, the counter written is incremented by the total number of bytes written to the output stream. This will be at least two plus the length of s, and at most two plus thrice the length of s.

22.21.17 public final int size()

The size method returns the current value of the counter written, the number of bytes written to the stream so far.


Contents | Prev | Next | Index

Java Language Specification (HTML generated by Suzette Pelouch on February 24, 1998)
Copyright © 1996 Sun Microsystems, Inc. All rights reserved
Please send any comments or corrections to doug.kramer@sun.com



Spec-Zone.ru - all specs in one place



free hit counter