org.apache.hadoop.fs
Class FSDataInputStream
java.lang.Object
java.io.InputStream
java.io.FilterInputStream
java.io.DataInputStream
org.apache.hadoop.fs.FSDataInputStream
- All Implemented Interfaces:
- Closeable, DataInput, PositionedReadable, Seekable
public class FSDataInputStream
- extends DataInputStream
- implements Seekable, PositionedReadable
Utility that wraps a FSInputStream
in a DataInputStream
and buffers input through a BufferedInputStream
.
Method Summary |
long |
getPos()
|
int |
read(long position,
byte[] buffer,
int offset,
int length)
Read upto the specified number of bytes, from a given
position within a file, and return the number of bytes read. |
void |
readFully(long position,
byte[] buffer)
Read number of bytes equalt to the length of the buffer, from a given
position within a file. |
void |
readFully(long position,
byte[] buffer,
int offset,
int length)
Read the specified number of bytes, from a given
position within a file. |
void |
seek(long desired)
Seek to the given offset from the start of the file. |
boolean |
seekToNewSource(long targetPos)
|
Methods inherited from class java.io.DataInputStream |
read, read, readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, readUTF, skipBytes |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
inStream
protected FSInputStream inStream
FSDataInputStream
public FSDataInputStream(FSInputStream in,
Configuration conf)
throws IOException
- Throws:
IOException
FSDataInputStream
public FSDataInputStream(FSInputStream in,
int bufferSize)
throws IOException
- Throws:
IOException
seek
public void seek(long desired)
throws IOException
- Description copied from interface:
Seekable
- Seek to the given offset from the start of the file.
The next read() will be from that location. Can't
seek past the end of the file.
- Specified by:
seek
in interface Seekable
- Throws:
IOException
getPos
public long getPos()
throws IOException
- Throws:
IOException
read
public int read(long position,
byte[] buffer,
int offset,
int length)
throws IOException
- Description copied from interface:
PositionedReadable
- Read upto the specified number of bytes, from a given
position within a file, and return the number of bytes read. This does not
change the current offset of a file, and is thread-safe.
- Specified by:
read
in interface PositionedReadable
- Throws:
IOException
readFully
public void readFully(long position,
byte[] buffer,
int offset,
int length)
throws IOException
- Description copied from interface:
PositionedReadable
- Read the specified number of bytes, from a given
position within a file. This does not
change the current offset of a file, and is thread-safe.
- Specified by:
readFully
in interface PositionedReadable
- Throws:
IOException
readFully
public void readFully(long position,
byte[] buffer)
throws IOException
- Description copied from interface:
PositionedReadable
- Read number of bytes equalt to the length of the buffer, from a given
position within a file. This does not
change the current offset of a file, and is thread-safe.
- Specified by:
readFully
in interface PositionedReadable
- Throws:
IOException
seekToNewSource
public boolean seekToNewSource(long targetPos)
throws IOException
- Throws:
IOException
Copyright © 2006 The Apache Software Foundation