public class HdfsRandomAccessContent extends AbstractRandomAccessContent
UnsupportedOperationException.| Constructor and Description |
|---|
HdfsRandomAccessContent(org.apache.hadoop.fs.Path path,
org.apache.hadoop.fs.FileSystem fs)
Create random access content.
|
| Modifier and Type | Method and Description |
|---|---|
void |
close()
Closes this random access file stream and releases any system resources associated with the stream.
|
long |
getFilePointer()
Returns the current offset in this file.
|
InputStream |
getInputStream()
Get the input stream.
|
long |
length()
Returns the length of this file.
|
boolean |
readBoolean() |
byte |
readByte() |
char |
readChar() |
double |
readDouble() |
float |
readFloat() |
void |
readFully(byte[] b) |
void |
readFully(byte[] b,
int off,
int len) |
int |
readInt() |
String |
readLine() |
long |
readLong() |
short |
readShort() |
int |
readUnsignedByte() |
int |
readUnsignedShort() |
String |
readUTF() |
void |
seek(long pos)
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.
|
void |
setLength(long newLength)
Sets the length of this content.
|
int |
skipBytes(int n) |
write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTFpublic HdfsRandomAccessContent(org.apache.hadoop.fs.Path path,
org.apache.hadoop.fs.FileSystem fs)
throws IOException
path - A Hadoop Pathfs - A Hadoop FileSystemIOException - when the path cannot be processed.public void close()
throws IOException
RandomAccessContentA closed random access file cannot perform input or output operations and cannot be reopened.
If this file has an associated channel then the channel is closed as well.
IOException - if an I/O error occurs.RandomAccessContent.close()public long getFilePointer()
throws IOException
RandomAccessContentIOException - if an I/O error occurs.RandomAccessContent.getFilePointer()public InputStream getInputStream() throws IOException
RandomAccessContent
Notice: If you use RandomAccessContent.seek(long) you have to re-get the InputStream
IOException - if an I/O error occurs.RandomAccessContent.getInputStream()public long length()
throws IOException
RandomAccessContentIOException - if an I/O error occurs.RandomAccessContent.length()public boolean readBoolean()
throws IOException
IOExceptionDataInput.readBoolean()public byte readByte()
throws IOException
IOExceptionDataInput.readByte()public char readChar()
throws IOException
IOExceptionDataInput.readChar()public double readDouble()
throws IOException
IOExceptionDataInput.readDouble()public float readFloat()
throws IOException
IOExceptionDataInput.readFloat()public void readFully(byte[] b)
throws IOException
IOExceptionDataInput.readFully(byte[])public void readFully(byte[] b,
int off,
int len)
throws IOException
IOExceptionDataInput.readFully(byte[], int, int)public int readInt()
throws IOException
IOExceptionDataInput.readInt()public String readLine() throws IOException
readLine in interface DataInputreadLine in class AbstractRandomAccessContentIOException - if an error occurs.DataInput.readLine()public long readLong()
throws IOException
IOExceptionDataInput.readLong()public short readShort()
throws IOException
IOExceptionDataInput.readShort()public int readUnsignedByte()
throws IOException
IOExceptionDataInput.readUnsignedByte()public int readUnsignedShort()
throws IOException
IOExceptionDataInput.readUnsignedShort()public String readUTF() throws IOException
IOExceptionDataInput.readUTF()public void seek(long pos)
throws IOException
RandomAccessContentThe offset may be set beyond the end of the file. Setting the offset beyond the end of the file does not change the file length. The file length will change only by writing after the offset has been set beyond the end of the file.
Notice: If you use RandomAccessContent.getInputStream() you have to re-get the InputStream after calling
RandomAccessContent.seek(long)
pos - the offset position, measured in bytes from the beginning of the file, at which to set the file
pointer.IOException - if pos is less than 0 or if an I/O error occurs.RandomAccessContent.seek(long)public void setLength(long newLength)
throws IOException
RandomAccessContent
If the the newLength argument is smaller than RandomAccessContent.length(), the content is truncated.
If the the newLength argument is greater than RandomAccessContent.length(), the content grows with undefined data.
newLength - The desired content lengthIOException - If an I/O error occursRandomAccessContent.setLength(long)public int skipBytes(int n)
throws IOException
IOExceptionDataInput.skipBytes(int)Copyright © 2002–2016 The Apache Software Foundation. All rights reserved.