java.io.DataOutputStream
java.io.FilterOutputStream
None
java.io.DataOutput
JDK 1.0 or later
The DataOutputStream class defines methods for writing primitive data types to an output stream in a machine-independent manner. Many of the methods of DataOutputStream write a single primitive data type, in binary format, to an underlying output stream. All multibyte quantities are written in a format that stores the most significant byte as the first byte and the least significant byte as the last byte.
public class java.io.DataOutputStream extends java.io.FilterOutputStream implements java.io.DataOutput { // Variables protected int written; // Constructors public DataOutputStream(OutputStream out); // Instance Methods public void flush(); public final int size(); public synchronized void write(int b); public synchronized void write(byte[] b, int off, int len); public final void writeBoolean(boolean v); public final void writeByte(int v); public final void writeBytes(String s); public final void writeChar(int v); public final void writeChars(String s); public final void writeDouble(double v); public final void writeFloat(float v); public final void writeInt(int v); public final void writeLong(long v); public final void writeShort(int v); public final void writeUTF(String str); }
The number of bytes that have been written to this output stream.
The output stream to use.
This constructor creates a DataOutputStream that uses out as its underlying stream.
If any kind of I/O error occurs.
FilterOutputStream.flush()
This method flushes the stream, forcing any buffered output to be written. The method calls the flush() method of the underlying output stream.
The number of bytes written.
This method returns the number of bytes that have been written to the stream (i.e., it returns the value of the variable written).
The value to write.
If any kind of I/O error occurs.
FilterOutputStream.write(int)
DataOutput.write(int)
This method writes the low-order eight bits of b to the underlying stream as a byte.
public synchronized void write(byte b[], int off, int len) throws IOException
An array of bytes to write.
An offset into the byte array.
The number of bytes to write.
If any kind of I/O error occurs.
FilterOutputStream.write(byte[], int, int)
DataOutput.write(byte[], int, int)
This method writes len bytes from the given array, starting off elements from the beginning of the array, to the underlying stream.
The boolean value to write.
If any kind of I/O error occurs.
DataOutput.writeBoolean()
If v is true, this method writes a byte that contains the value 1 to the underlying stream. If v is false, the method writes a byte that contains the value 0.
The value to write.
If any kind of I/O error occurs.
DataOutput.writeByte()
This method writes an 8-bit byte to the underlying stream, using the low-order eight bits of the given integer v.
The String to write.
If any kind of I/O error occurs.
DataOutput.writeBytes()
This method writes the characters in the given String to the underlying stream as a sequence of 8-bit bytes. The high-order bytes of the characters in the string are ignored.
The value to write.
If any kind of I/O error occurs.
DataOutput.writeChar()
This method writes a 16-bit char to the underlying stream, using the low-order 16 bits of the given integer v.
The String to write.
If any kind of I/O error occurs.
DataOutput.writeChars()
This method writes the characters in the given String object to the underlying stream as a sequence of 16-bit characters.
The double value to write.
If any kind of I/O error occurs.
DataOutput.writeDouble()
This method writes a 64-bit double to the underlying stream. The double value is converted to a long using doubleToLongBits() of Double; the long value is then written to the underlying stream as eight bytes with the high-order byte first.
The float value to write.
If any kind of I/O error occurs.
DataOutput.writeFloat()
This method writes a 32-bit float to the underlying stream. The float value is converted to a int using floatToIntBits() of Float; the int value is then written to the underlying stream as four bytes with the high-order byte first.
The int value to write.
If any kind of I/O error occurs.
DataOutput.writeInt()
This method writes a 32-bit int to the underlying stream. The value is written as four bytes with the high-order byte first.
The long value to write.
If any kind of I/O error occurs.
DataOutput.writeLong()
This method writes a 64-bit long to the underlying stream. The value is written as eight bytes with the high-order byte first.
The value to write.
If any kind of I/O error occurs.
DataOutput.writeShort()
This method writes a 16-bit short to the underlying stream, using the low-order two bytes of the given integer v.
The String to write.
If any kind of I/O error occurs.
DataOutput.writeUTF()
This method writes the given String to the underlying stream using the UTF-8 encoding. First, two bytes are written as an unsigned short value; this value specifies the number of bytes to follow. The value is the actual number of bytes in the UTF-8 encoding, not the length of the string. Then each character of the string is written as UTF-8 encoded bytes.
See Appendix B, The UTF-8 Encoding for more information on the UTF-8 encoding.
Method |
Inherited From |
Method |
Inherited From |
---|---|---|---|
clone() |
Object |
close() |
FilterOutputStream |
equals(Object) |
Object |
finalize() |
Object |
getClass() |
Object |
hashCode() |
Object |
notify() |
Object |
notifyAll() |
Object |
toString() |
Object |
wait() |
Object |
wait(long) |
Object |
wait(long, int) |
Object |
write(byte[]) |
FilterOutputStream |
DataInputStream, DataOutput, Double, FilterOutputStream, Float, IOException, OutputStream