FileDocCategorySizeDatePackage
DataInput.javaAPI DocAndroid 1.5 API9826Wed May 06 22:41:04 BST 2009java.io

DataInput

public interface DataInput
Defines an interface for classes that are able to read typed data from some source. Typically, this data has been written by a class which implements {@link DataOutput}. Types that can be read include byte, 16-bit short, 32-bit int, 32-bit float, 64-bit long, 64-bit double, byte strings, and MUTF-8 strings.

MUTF-8 (Modified UTF-8) Encoding

When encoding strings as UTF, implementations of {@code DataInput} and {@code DataOutput} use a slightly modified form of UTF-8, hereafter referred to as MUTF-8. This form is identical to standard UTF-8, except:

  • Only the one-, two-, and three-byte encodings are used.
  • Code points in the range U+10000U+10ffff are encoded as a surrogate pair, each of which is represented as a three-byte encoded value.
  • The code point U+0000 is encoded in two-byte form.

Please refer to The Unicode Standard for further information about character encoding. MUTF-8 is actually closer to the (relatively less well-known) encoding CESU-8 than to UTF-8 per se.

see
DataInputStream
see
RandomAccessFile
since
Android 1.0

Fields Summary
Constructors Summary
Methods Summary
public abstract booleanreadBoolean()
Reads a boolean.

return
the next boolean value.
throws
EOFException if the end of the input is reached before the read request can be satisfied.
throws
IOException if an I/O error occurs while reading.
see
DataOutput#writeBoolean(boolean)
since
Android 1.0

public abstract bytereadByte()
Reads an 8-bit byte value.

return
the next byte value.
throws
EOFException if the end of the input is reached before the read request can be satisfied.
throws
IOException if an I/O error occurs while reading.
see
DataOutput#writeByte(int)
since
Android 1.0

public abstract charreadChar()
Reads a 16-bit character value.

return
the next char value.
throws
EOFException if the end of the input is reached before the read request can be satisfied.
throws
IOException if an I/O error occurs while reading.
see
DataOutput#writeChar(int)
since
Android 1.0

public abstract doublereadDouble()
Reads a 64-bit double value.

return
the next double value.
throws
EOFException if the end of the input is reached before the read request can be satisfied.
throws
IOException if an I/O error occurs while reading.
see
DataOutput#writeDouble(double)
since
Android 1.0

public abstract floatreadFloat()
Reads a 32-bit float value.

return
the next float value.
throws
EOFException if the end of the input is reached before the read request can be satisfied.
throws
IOException if an I/O error occurs while reading.
see
DataOutput#writeFloat(float)
since
Android 1.0

public abstract voidreadFully(byte[] buffer)
Reads bytes into the byte array {@code buffer}. This method will block until {@code buffer.length} number of bytes have been read.

param
buffer the buffer to read bytes into.
throws
EOFException if the end of the input is reached before the read request can be satisfied.
throws
IOException if an I/O error occurs while reading.
see
DataOutput#write(byte[])
see
DataOutput#write(byte[], int, int)
since
Android 1.0

public abstract voidreadFully(byte[] buffer, int offset, int count)
Reads bytes and stores them in the byte array {@code buffer} starting at offset {@code offset}. This method blocks until {@code count} number of bytes have been read.

param
buffer the byte array in which to store the bytes read.
param
offset the initial position in {@code buffer} to store the bytes read.
param
count the maximum number of bytes to store in {@code buffer}.
throws
EOFException if the end of the input is reached before the read request can be satisfied.
throws
IOException if an I/O error occurs while reading.
see
DataOutput#write(byte[])
see
DataOutput#write(byte[], int, int)
since
Android 1.0

public abstract intreadInt()
Reads a 32-bit integer value.

return
the next int value.
throws
EOFException if the end of the input is reached before the read request can be satisfied.
throws
IOException if an I/O error occurs while reading.
see
DataOutput#writeInt(int)
since
Android 1.0

public abstract java.lang.StringreadLine()
Returns a string containing the next line of text available from this stream. A line is made of zero or more characters followed by {@code '\n'}, {@code '\r'}, {@code "\r\n"} or the end of the stream. The string does not include the newline sequence.

return
the contents of the line or null if no characters have been read before the end of the stream.
throws
EOFException if the end of the input is reached before the read request can be satisfied.
throws
IOException if an I/O error occurs while reading.
since
Android 1.0

public abstract longreadLong()
Reads a 64-bit long value.

return
the next long value.
throws
EOFException if the end of the input is reached before the read request can be satisfied.
throws
IOException if an I/O error occurs while reading.
see
DataOutput#writeLong(long)
since
Android 1.0

public abstract shortreadShort()
Reads a 16-bit short value.

return
the next short value.
throws
EOFException if the end of the input is reached before the read request can be satisfied.
throws
IOException if an I/O error occurs while reading.
see
DataOutput#writeShort(int)
since
Android 1.0

public abstract java.lang.StringreadUTF()
Reads a string encoded with {@link DataInput modified UTF-8}.

return
the next string encoded with {@link DataInput modified UTF-8}.
throws
EOFException if the end of the input is reached before the read request can be satisfied.
throws
IOException if an I/O error occurs while reading.
see
DataOutput#writeUTF(java.lang.String)
since
Android 1.0

public abstract intreadUnsignedByte()
Reads an unsigned 8-bit byte value and returns it as an int.

return
the next unsigned byte value.
throws
EOFException if the end of the input is reached before the read request can be satisfied.
throws
IOException if an I/O error occurs while reading.
see
DataOutput#writeByte(int)
since
Android 1.0

public abstract intreadUnsignedShort()
Reads a 16-bit unsigned short value and returns it as an int.

return
the next unsigned short value.
throws
EOFException if the end of the input is reached before the read request can be satisfied.
throws
IOException if an I/O error occurs while reading.
see
DataOutput#writeShort(int)
since
Android 1.0

public abstract intskipBytes(int count)
Skips {@code count} number of bytes. This method will not throw an {@link EOFException} if the end of the input is reached before {@code count} bytes where skipped.

param
count the number of bytes to skip.
return
the number of bytes actually skipped.
throws
IOException if a problem occurs during skipping.
since
Android 1.0