public abstract class AbstractDataInput
extends java.io.InputStream
implements java.io.DataInput
Constructor and Description |
---|
AbstractDataInput() |
Modifier and Type | Method and Description |
---|---|
protected abstract int |
getPosition() |
boolean |
readBoolean()
Reads a boolean from the current position in this file.
|
byte |
readByte()
Reads an 8-bit byte from the current position in this file.
|
char |
readChar()
Reads a 16-bit character from the current position in this file.
|
double |
readDouble()
Reads a 64-bit double from the current position in this file.
|
float |
readFloat()
Reads a 32-bit float from the current position in this file.
|
void |
readFully(byte[] buffer)
Reads bytes from this file into
buffer . |
void |
readFully(byte[] buffer,
int offset,
int count)
Read bytes from this file into
buffer starting at offset offset . |
int |
readInt()
Reads a 32-bit integer from the current position in this file.
|
java.lang.String |
readLine()
Reads a line of text form the current position in this file.
|
long |
readLong()
Reads a 64-bit long from the current position in this file.
|
short |
readShort()
Reads a 16-bit short from the current position in this file.
|
int |
readUnsignedByte()
Reads an unsigned 8-bit byte from the current position in this file and
returns it as an integer.
|
int |
readUnsignedShort()
Reads an unsigned 16-bit short from the current position in this file and
returns it as an integer.
|
java.lang.String |
readUTF()
Reads a string that is encoded in
modified UTF-8 from
this file. |
protected abstract void |
seekInternal(int position) |
available, close, mark, markSupported, read, read, read, reset, skip
protected abstract void seekInternal(int position)
protected abstract int getPosition()
public final boolean readBoolean() throws java.io.IOException
readBoolean
in interface java.io.DataInput
java.io.EOFException
- if the end of this file is detected.java.io.IOException
- if this file is closed or another I/O error occurs.public final byte readByte() throws java.io.IOException
readByte
in interface java.io.DataInput
java.io.EOFException
- if the end of this file is detected.java.io.IOException
- if this file is closed or another I/O error occurs.public final char readChar() throws java.io.IOException
readChar
in interface java.io.DataInput
java.io.EOFException
- if the end of this file is detected.java.io.IOException
- if this file is closed or another I/O error occurs.public final double readDouble() throws java.io.IOException
readDouble
in interface java.io.DataInput
java.io.EOFException
- if the end of this file is detected.java.io.IOException
- if this file is closed or another I/O error occurs.public final float readFloat() throws java.io.IOException
readFloat
in interface java.io.DataInput
java.io.EOFException
- if the end of this file is detected.java.io.IOException
- if this file is closed or another I/O error occurs.public void readFully(byte[] buffer) throws java.io.IOException
buffer
. Blocks until buffer.length
number of bytes have been read, the end of the file is
reached or an exception is thrown.readFully
in interface java.io.DataInput
buffer
- the buffer to read bytes into.java.io.EOFException
- if the end of this file is detected.java.io.IOException
- if this file is closed or another I/O error occurs.java.lang.NullPointerException
- if buffer
is null
.public void readFully(byte[] buffer, int offset, int count) throws java.io.IOException
buffer
starting at offset offset
. This method blocks until count
number of bytes have been
read.readFully
in interface java.io.DataInput
buffer
- the buffer to read bytes into.offset
- the initial position in buffer
to store the bytes read
from this file.count
- the maximum number of bytes to store in buffer
.java.io.EOFException
- if the end of this file is detected.java.lang.IndexOutOfBoundsException
- if offset < 0
or count < 0
, or if offset + count
is greater than the length of buffer
.java.io.IOException
- if this file is closed or another I/O error occurs.java.lang.NullPointerException
- if buffer
is null
.public int readInt() throws java.io.IOException
readInt
in interface java.io.DataInput
java.io.EOFException
- if the end of this file is detected.java.io.IOException
- if this file is closed or another I/O error occurs.public final java.lang.String readLine() throws java.io.IOException
'\n'
, '\r'
, "\r\n"
or the end of file marker. The string does not
include the line terminating sequence.
Blocks until a line terminating sequence has been read, the end of the file is reached or an exception is thrown.
readLine
in interface java.io.DataInput
null
if no characters have
been read before the end of the file has been reached.java.io.IOException
- if this file is closed or another I/O error occurs.public long readLong() throws java.io.IOException
readLong
in interface java.io.DataInput
java.io.EOFException
- if the end of this file is detected.java.io.IOException
- if this file is closed or another I/O error occurs.public short readShort() throws java.io.IOException
readShort
in interface java.io.DataInput
java.io.EOFException
- if the end of this file is detected.java.io.IOException
- if this file is closed or another I/O error occurs.public final int readUnsignedByte() throws java.io.IOException
readUnsignedByte
in interface java.io.DataInput
java.io.EOFException
- if the end of this file is detected.java.io.IOException
- if this file is closed or another I/O error occurs.public int readUnsignedShort() throws java.io.IOException
readUnsignedShort
in interface java.io.DataInput
java.io.EOFException
- if the end of this file is detected.java.io.IOException
- if this file is closed or another I/O error occurs.public final java.lang.String readUTF() throws java.io.IOException
modified UTF-8
from
this file. The number of bytes that must be read for the complete string
is determined by the first two bytes read from the file. Blocks until all
required bytes have been read, the end of the file is reached or an
exception is thrown.readUTF
in interface java.io.DataInput
modified UTF-8
from
this file.java.io.EOFException
- if the end of this file is detected.java.io.IOException
- if this file is closed or another I/O error occurs.java.io.UTFDataFormatException
- if the bytes read cannot be decoded into a character string.Copyright © 2014 The Apache Software Foundation