DataOutputStream class methods in Java

java.io.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.


Some methods of DataOutputStream class

close()This method closes this output stream and releases any system resources associated with the stream.

flush()This method flushes this data output stream. This forces any buffered output bytes to be written out to the stream.

size()This method returns the current value of the counter written, and the number of bytes written to this data output stream so far.

write(byte[])This method writes b.length bytes to this output stream.

write(int)This method writes the specified byte to the underlying output stream.

write(byte[], int, int)This method writes len bytes from the specified byte array starting at offset off to the underlying output stream.

writeBoolean(boolean)This method writes a boolean to the underlying output stream as a 1-byte value.

writeByte(int)This method writes out a byte to the underlying output stream as a 1-byte value.

writeBytes(String)This method writes out the string to the underlying output stream as a sequence of bytes.

writeChar(int) This method writes a char to the underlying output stream as a 2-byte value, high byte first.

writeChars(String)This method writes a string to the underlying output stream as a sequence of characters.

writeDouble(double)This method converts the double argument to a long using the doubleToLongBits method in class Double and then writes that long value to the underlying output stream as an 8-byte quantity, high byte first.

writeFloat(float)This method converts the float argument to an int using the floatToIntBits method in class Float and then writes that int value to the underlying output stream as a 4-byte quantity, high byte first.

writeInt(int)This method writes an int to the underlying output stream as four bytes, the high byte first.

writeLong(long)This method writes a long to the underlying output stream as eight bytes, high byte first.

writeShort(int) This method writes a short to the underlying output stream as two bytes, the high byte first.

writeUTF(String)This method writes a string to the underlying output stream using modified UTF-8 encoding in a machine-independent manner.


No comments:

Post a Comment