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, writeUTF
public 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
RandomAccessContent
A 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
RandomAccessContent
IOException
- 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
RandomAccessContent
IOException
- if an I/O error occurs.RandomAccessContent.length()
public boolean readBoolean() throws IOException
IOException
DataInput.readBoolean()
public byte readByte() throws IOException
IOException
DataInput.readByte()
public char readChar() throws IOException
IOException
DataInput.readChar()
public double readDouble() throws IOException
IOException
DataInput.readDouble()
public float readFloat() throws IOException
IOException
DataInput.readFloat()
public void readFully(byte[] b) throws IOException
IOException
DataInput.readFully(byte[])
public void readFully(byte[] b, int off, int len) throws IOException
IOException
DataInput.readFully(byte[], int, int)
public int readInt() throws IOException
IOException
DataInput.readInt()
public String readLine() throws IOException
readLine
in interface DataInput
readLine
in class AbstractRandomAccessContent
IOException
- if an error occurs.DataInput.readLine()
public long readLong() throws IOException
IOException
DataInput.readLong()
public short readShort() throws IOException
IOException
DataInput.readShort()
public int readUnsignedByte() throws IOException
IOException
DataInput.readUnsignedByte()
public int readUnsignedShort() throws IOException
IOException
DataInput.readUnsignedShort()
public String readUTF() throws IOException
IOException
DataInput.readUTF()
public void seek(long pos) throws IOException
RandomAccessContent
The 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
IOException
DataInput.skipBytes(int)
Copyright © 2002–2020 The Apache Software Foundation. All rights reserved.