Package java.io
Interface DataOutput
-
- All Known Subinterfaces:
ObjectOutput
- All Known Implementing Classes:
DataOutputStream,ObjectOutputStream,RandomAccessFile
public interface DataOutputDefines an interface for classes that are able to write big-endian typed data to some target. Typically, this data can be read in by a class which implements DataInput. Types that can be written include byte, 16-bit short, 32-bit int, 32-bit float, 64-bit long, 64-bit double, byte strings, andMUTF-8encoded strings.- See Also:
DataOutputStream,RandomAccessFile
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description voidwrite(byte[] buffer)Writes the entire contents of the byte arraybufferto this stream.voidwrite(byte[] buffer, int offset, int count)Writescountbytes from the byte arraybufferstarting at offsetindex.voidwrite(int oneByte)Writes the specified 8-bit byte.voidwriteBoolean(boolean val)Writes the specified boolean.voidwriteByte(int val)Writes the specified 8-bit byte.voidwriteBytes(String str)Writes the low order 8-bit bytes from the specified string.voidwriteChar(int val)Writes the specified 16-bit character in big-endian order.voidwriteChars(String str)Writes the 16-bit characters contained instrin big-endian order.voidwriteDouble(double val)Writes the specified 64-bit double in big-endian order.voidwriteFloat(float val)Writes the specified 32-bit float in big-endian order.voidwriteInt(int val)Writes the specified 32-bit int in big-endian order.voidwriteLong(long val)Writes the specified 64-bit long in big-endian order.voidwriteShort(int val)Writes the specified 16-bit short in big-endian order.voidwriteUTF(String str)Writes the specified string encoded inmodified UTF-8.
-
-
-
Method Detail
-
write
void write(byte[] buffer) throws IOExceptionWrites the entire contents of the byte arraybufferto this stream.- Parameters:
buffer- the buffer to write.- Throws:
IOException- if an I/O error occurs while writing.
-
write
void write(byte[] buffer, int offset, int count) throws IOExceptionWritescountbytes from the byte arraybufferstarting at offsetindex.- Parameters:
buffer- the buffer to write.offset- the index of the first byte inbufferto write.count- the number of bytes from thebufferto write.- Throws:
IOException- if an I/O error occurs while writing.
-
write
void write(int oneByte) throws IOExceptionWrites the specified 8-bit byte.- Parameters:
oneByte- the byte to write.- Throws:
IOException- if an I/O error occurs while writing.- See Also:
DataInput.readByte()
-
writeBoolean
void writeBoolean(boolean val) throws IOExceptionWrites the specified boolean.- Parameters:
val- the boolean value to write.- Throws:
IOException- if an I/O error occurs while writing.- See Also:
DataInput.readBoolean()
-
writeByte
void writeByte(int val) throws IOExceptionWrites the specified 8-bit byte.- Parameters:
val- the byte value to write.- Throws:
IOException- if an I/O error occurs while writing.- See Also:
DataInput.readByte(),DataInput.readUnsignedByte()
-
writeBytes
void writeBytes(String str) throws IOException
Writes the low order 8-bit bytes from the specified string.- Parameters:
str- the string containing the bytes to write.- Throws:
IOException- if an I/O error occurs while writing.
-
writeChar
void writeChar(int val) throws IOExceptionWrites the specified 16-bit character in big-endian order. Only the two least significant bytes of the integeroneByteare written.- Parameters:
val- the character to write.- Throws:
IOException- if an I/O error occurs while writing.- See Also:
DataInput.readChar()
-
writeChars
void writeChars(String str) throws IOException
Writes the 16-bit characters contained instrin big-endian order.- Parameters:
str- the string that contains the characters to write.- Throws:
IOException- if an I/O error occurs while writing.- See Also:
DataInput.readChar()
-
writeDouble
void writeDouble(double val) throws IOExceptionWrites the specified 64-bit double in big-endian order. The resulting output is the eight bytes returned byDouble.doubleToLongBits(double).- Parameters:
val- the double to write.- Throws:
IOException- if an I/O error occurs while writing.- See Also:
DataInput.readDouble()
-
writeFloat
void writeFloat(float val) throws IOExceptionWrites the specified 32-bit float in big-endian order. The resulting output is the four bytes returned byFloat.floatToIntBits(float).- Parameters:
val- the float to write.- Throws:
IOException- if an I/O error occurs while writing.- See Also:
DataInput.readFloat()
-
writeInt
void writeInt(int val) throws IOExceptionWrites the specified 32-bit int in big-endian order.- Parameters:
val- the int to write.- Throws:
IOException- if an I/O error occurs while writing.- See Also:
DataInput.readInt()
-
writeLong
void writeLong(long val) throws IOExceptionWrites the specified 64-bit long in big-endian order.- Parameters:
val- the long to write.- Throws:
IOException- if an I/O error occurs while writing.- See Also:
DataInput.readLong()
-
writeShort
void writeShort(int val) throws IOExceptionWrites the specified 16-bit short in big-endian order. Only the lower two bytes ofvalare written.- Parameters:
val- the short to write.- Throws:
IOException- if an I/O error occurs while writing.- See Also:
DataInput.readShort(),DataInput.readUnsignedShort()
-
writeUTF
void writeUTF(String str) throws IOException
Writes the specified string encoded inmodified UTF-8.- Parameters:
str- the string to write encoded inmodified UTF-8.- Throws:
IOException- if an I/O error occurs while writing.- See Also:
DataInput.readUTF()
-
-