written
boolean
true
(byte)1
false
(byte)0
1
byte
short
2
char
int
4
long
8
floatToIntBits
Float
float
doubleToLongBits
Double
double
readBoolean
DataInput
* Bytes for this operation are read from the contained * input stream. * * @return the boolean value read. * @exception EOFException if this input stream has reached the end. * @exception IOException the stream has been closed and the contained * input stream does not support reading after close, or * another I/O error occurs. * @see java.io.FilterInputStream#in */ public final boolean readBoolean() throws IOException { int ch = in.read(); if (ch < 0) throw new EOFException(); return (ch != 0); } /** * See the general contract of the readByte * method of DataInput. *
readByte
* Bytes * for this operation are read from the contained * input stream. * * @return the next byte of this input stream as a signed 8-bit * byte. * @exception EOFException if this input stream has reached the end. * @exception IOException the stream has been closed and the contained * input stream does not support reading after close, or * another I/O error occurs. * @see java.io.FilterInputStream#in */ public final byte readByte() throws IOException { int ch = in.read(); if (ch < 0) throw new EOFException(); return (byte)(ch); } /** * See the general contract of the readUnsignedByte * method of DataInput. *
readUnsignedByte
* Bytes * for this operation are read from the contained * input stream. * * @return the next byte of this input stream, interpreted as an * unsigned 8-bit number. * @exception EOFException if this input stream has reached the end. * @exception IOException the stream has been closed and the contained * input stream does not support reading after close, or * another I/O error occurs. * @see java.io.FilterInputStream#in */ public final int readUnsignedByte() throws IOException { int ch = in.read(); if (ch < 0) throw new EOFException(); return ch; } /** * See the general contract of the readShort * method of DataInput. *
readShort
* Bytes * for this operation are read from the contained * input stream. * * @return the next two bytes of this input stream, interpreted as a * signed 16-bit number. * @exception EOFException if this input stream reaches the end before * reading two bytes. * @exception IOException the stream has been closed and the contained * input stream does not support reading after close, or * another I/O error occurs. * @see java.io.FilterInputStream#in */ public final short readShort() throws IOException { int ch1 = in.read(); int ch2 = in.read(); if ((ch1 | ch2) < 0) throw new EOFException(); return (short)((ch1 << 8) + (ch2 << 0)); }
readUnsignedShort
* Bytes * for this operation are read from the contained * input stream. * * @return the next two bytes of this input stream, interpreted as an * unsigned 16-bit integer. * @exception EOFException if this input stream reaches the end before * reading two bytes. * @exception IOException the stream has been closed and the contained * input stream does not support reading after close, or * another I/O error occurs. * @see java.io.FilterInputStream#in */ public final int readUnsignedShort() throws IOException { int ch1 = in.read(); int ch2 = in.read(); if ((ch1 | ch2) < 0) throw new EOFException(); return (ch1 << 8) + (ch2 << 0); } /** * See the general contract of the readChar * method of DataInput. *
readChar
* Bytes * for this operation are read from the contained * input stream. * * @return the next two bytes of this input stream, interpreted as a * char. * @exception EOFException if this input stream reaches the end before * reading two bytes. * @exception IOException the stream has been closed and the contained * input stream does not support reading after close, or * another I/O error occurs. * @see java.io.FilterInputStream#in */ public final char readChar() throws IOException { int ch1 = in.read(); int ch2 = in.read(); if ((ch1 | ch2) < 0) throw new EOFException(); return (char)((ch1 << 8) + (ch2 << 0)); } /** * See the general contract of the readInt * method of DataInput. *
readInt
* Bytes * for this operation are read from the contained * input stream. * * @return the next four bytes of this input stream, interpreted as an * int. * @exception EOFException if this input stream reaches the end before * reading four bytes. * @exception IOException the stream has been closed and the contained * input stream does not support reading after close, or * another I/O error occurs. * @see java.io.FilterInputStream#in */ public final int readInt() throws IOException { int ch1 = in.read(); int ch2 = in.read(); int ch3 = in.read(); int ch4 = in.read(); if ((ch1 | ch2 | ch3 | ch4) < 0) throw new EOFException(); return ((ch1 << 24) + (ch2 << 16) + (ch3 << 8) + (ch4 << 0)); }
readLong
* Bytes * for this operation are read from the contained * input stream. * * @return the next eight bytes of this input stream, interpreted as a * long. * @exception EOFException if this input stream reaches the end before * reading eight bytes. * @exception IOException the stream has been closed and the contained * input stream does not support reading after close, or * another I/O error occurs. * @see java.io.FilterInputStream#in */ public final long readLong() throws IOException { readFully(readBuffer, 0, 8); return (((long)readBuffer[0] << 56) + ((long)(readBuffer[1] & 255) << 48) + ((long)(readBuffer[2] & 255) << 40) + ((long)(readBuffer[3] & 255) << 32) + ((long)(readBuffer[4] & 255) << 24) + ((readBuffer[5] & 255) << 16) + ((readBuffer[6] & 255) << 8) + ((readBuffer[7] & 255) << 0)); } /** * See the general contract of the readFloat * method of DataInput. *
readFloat
* Bytes * for this operation are read from the contained * input stream. * * @return the next four bytes of this input stream, interpreted as a * float. * @exception EOFException if this input stream reaches the end before * reading four bytes. * @exception IOException the stream has been closed and the contained * input stream does not support reading after close, or * another I/O error occurs. * @see java.io.DataInputStream#readInt() * @see java.lang.Float#intBitsToFloat(int) */ public final float readFloat() throws IOException { return Float.intBitsToFloat(readInt()); }
readDouble
* Bytes * for this operation are read from the contained * input stream. * * @return the next eight bytes of this input stream, interpreted as a * double. * @exception EOFException if this input stream reaches the end before * reading eight bytes. * @exception IOException the stream has been closed and the contained * input stream does not support reading after close, or * another I/O error occurs. * @see java.io.DataInputStream#readLong() * @see java.lang.Double#longBitsToDouble(long) */ public final double readDouble() throws IOException { return Double.longBitsToDouble(readLong()); }