public class ByteBufferRandomAccessFile extends java.lang.Object implements IRandomAccessFile
IRandomAccessFile
based on a ByteBuffer
.
Does not implement IRandomAccessFile.readLine()
.
Constructor and Description |
---|
ByteBufferRandomAccessFile(byte[] array)
Creates a
IRandomAccessFile wrapper for the given array. |
ByteBufferRandomAccessFile(byte[] array,
int initialLength)
Creates a
IRandomAccessFile wrapper for the given array. |
ByteBufferRandomAccessFile(java.nio.ByteBuffer buf)
Creates a
IRandomAccessFile wrapper for the given buf. |
ByteBufferRandomAccessFile(java.nio.ByteBuffer buf,
int initialLength)
Creates a
IRandomAccessFile wrapper for the given buf. |
ByteBufferRandomAccessFile(int capacity)
Creates a
IRandomAccessFile wrapper for a ByteBuffer with
capacity. |
Modifier and Type | Method and Description |
---|---|
int |
available() |
void |
close() |
void |
flush() |
java.nio.ByteOrder |
getByteOrder()
Gets the byte-order (endiness) of the random access file.
|
long |
getFilePointer()
Returns the current offset in this file.
|
long |
length()
Returns the length of this file.
|
void |
mark(int readlimit) |
boolean |
markSupported() |
int |
read() |
int |
read(byte[] b) |
int |
read(byte[] b,
int off,
int len) |
boolean |
readBoolean() |
byte |
readByte() |
char |
readChar() |
double |
readDouble() |
float |
readFloat() |
void |
readFully(byte[] b) |
void |
readFully(byte[] b,
int off,
int len) |
int |
readInt() |
java.lang.String |
readLine() |
long |
readLong() |
short |
readShort() |
int |
readUnsignedByte() |
int |
readUnsignedShort() |
java.lang.String |
readUTF() |
void |
reset() |
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 |
setByteOrder(java.nio.ByteOrder byteOrder)
Sets the byte-order (endiness) of the random access file.
|
void |
setLength(long newLength)
Sets the length of this file.
|
long |
skip(long n) |
int |
skipBytes(int n) |
void |
synchronize()
Performs a synchronization of the resource.
|
void |
write(byte[] b) |
void |
write(byte[] b,
int off,
int len) |
void |
write(int b) |
void |
writeBoolean(boolean v) |
void |
writeByte(int v) |
void |
writeBytes(java.lang.String s) |
void |
writeChar(int v) |
void |
writeChars(java.lang.String s) |
void |
writeDouble(double v) |
void |
writeFloat(float v) |
void |
writeInt(int v) |
void |
writeLong(long v) |
void |
writeShort(int v) |
void |
writeUTF(java.lang.String str) |
public ByteBufferRandomAccessFile(java.nio.ByteBuffer buf, int initialLength)
IRandomAccessFile
wrapper for the given buf.buf
- The buffer to wrap.initialLength
- The initially set length (corresponds to the Buffer.limit()
).public ByteBufferRandomAccessFile(java.nio.ByteBuffer buf)
IRandomAccessFile
wrapper for the given buf. Does not change the
Buffer.limit()
of buf.buf
- The buffer to wrap.public ByteBufferRandomAccessFile(byte[] array, int initialLength)
IRandomAccessFile
wrapper for the given array.array
- The byte array to wrap.initialLength
- The initially set length.public ByteBufferRandomAccessFile(byte[] array)
IRandomAccessFile
wrapper for the given array. The initial
Buffer.limit()
will be array.length
.array
- The byte array to wrap.public ByteBufferRandomAccessFile(int capacity)
IRandomAccessFile
wrapper for a ByteBuffer
with
capacity. The initial Buffer.limit()
will be 0
.capacity
- The maximal size of the ByteBuffer
.public java.nio.ByteOrder getByteOrder()
IRandomAccessFile
getByteOrder
in interface IRandomAccessFile
public void setByteOrder(java.nio.ByteOrder byteOrder)
IRandomAccessFile
setByteOrder
in interface IRandomAccessFile
public void readFully(byte[] b) throws IOExceptionUnchecked
readFully
in interface IRandomAccessFile
readFully
in interface java.io.DataInput
IOExceptionUnchecked
DataInput.readFully(byte[])
public void readFully(byte[] b, int off, int len) throws IOExceptionUnchecked
readFully
in interface IRandomAccessFile
readFully
in interface java.io.DataInput
IOExceptionUnchecked
DataInput.readFully(byte[], int, int)
public int skipBytes(int n) throws IOExceptionUnchecked
skipBytes
in interface IRandomAccessFile
skipBytes
in interface java.io.DataInput
IOExceptionUnchecked
DataInput.skipBytes(int)
public void close() throws IOExceptionUnchecked
close
in interface IInputStream
close
in interface IOutputStream
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
IOExceptionUnchecked
InputStream.close()
public int read() throws IOExceptionUnchecked
read
in interface IInputStream
IOExceptionUnchecked
InputStream.read()
public int read(byte[] b) throws IOExceptionUnchecked
read
in interface IInputStream
IOExceptionUnchecked
InputStream.read(byte[])
public int read(byte[] b, int off, int len) throws IOExceptionUnchecked
read
in interface IInputStream
IOExceptionUnchecked
InputStream.read(byte[], int, int)
public long skip(long n) throws IOExceptionUnchecked
skip
in interface IInputStream
IOExceptionUnchecked
InputStream.skip(long)
public int available() throws IOExceptionUnchecked
available
in interface IInputStream
IOExceptionUnchecked
InputStream.available()
public void mark(int readlimit)
mark
in interface IInputStream
InputStream.mark(int)
public void reset() throws IOExceptionUnchecked
reset
in interface IInputStream
IOExceptionUnchecked
InputStream.reset()
public boolean markSupported()
markSupported
in interface IInputStream
InputStream.markSupported()
public void flush() throws IOExceptionUnchecked
flush
in interface IOutputStream
IOExceptionUnchecked
OutputStream.flush()
public void synchronize() throws IOExceptionUnchecked
ISynchronizable
synchronize
in interface IOutputStream
synchronize
in interface ISynchronizable
IOExceptionUnchecked
OutputStream.flush()
public long getFilePointer() throws IOExceptionUnchecked
IRandomAccessFile
getFilePointer
in interface IRandomAccessFile
IOExceptionUnchecked
- if an I/O error occurs.public void seek(long pos) throws IOExceptionUnchecked
IRandomAccessFile
seek
in interface IRandomAccessFile
pos
- the offset position, measured in bytes from the beginning of the file, at which to
set the file pointer.IOExceptionUnchecked
- if pos
is less than 0
or if an I/O
error occurs.public long length() throws IOExceptionUnchecked
IRandomAccessFile
length
in interface IRandomAccessFile
IOExceptionUnchecked
- if an I/O error occurs.public void setLength(long newLength) throws IOExceptionUnchecked
IRandomAccessFile
If the present length of the file as returned by the length
method is greater
than the newLength
argument then the file will be truncated. In this case, if
the file offset as returned by the getFilePointer
method is greater than
newLength
then after this method returns the offset will be equal to
newLength
.
If the present length of the file as returned by the length
method is smaller
than the newLength
argument then the file will be extended. In this case, the
contents of the extended portion of the file are not defined.
setLength
in interface IRandomAccessFile
newLength
- The desired length of the fileIOExceptionUnchecked
- If an I/O error occurspublic boolean readBoolean() throws IOExceptionUnchecked
readBoolean
in interface IRandomAccessFile
readBoolean
in interface java.io.DataInput
IOExceptionUnchecked
DataInput.readBoolean()
public byte readByte() throws IOExceptionUnchecked
readByte
in interface IRandomAccessFile
readByte
in interface java.io.DataInput
IOExceptionUnchecked
DataInput.readByte()
public int readUnsignedByte() throws IOExceptionUnchecked
readUnsignedByte
in interface IRandomAccessFile
readUnsignedByte
in interface java.io.DataInput
IOExceptionUnchecked
DataInput.readUnsignedByte()
public short readShort() throws IOExceptionUnchecked
readShort
in interface IRandomAccessFile
readShort
in interface java.io.DataInput
IOExceptionUnchecked
DataInput.readShort()
public int readUnsignedShort() throws IOExceptionUnchecked
readUnsignedShort
in interface IRandomAccessFile
readUnsignedShort
in interface java.io.DataInput
IOExceptionUnchecked
DataInput.readUnsignedShort()
public char readChar() throws IOExceptionUnchecked
readChar
in interface IRandomAccessFile
readChar
in interface java.io.DataInput
IOExceptionUnchecked
DataInput.readChar()
public int readInt() throws IOExceptionUnchecked
readInt
in interface IRandomAccessFile
readInt
in interface java.io.DataInput
IOExceptionUnchecked
DataInput.readInt()
public long readLong() throws IOExceptionUnchecked
readLong
in interface IRandomAccessFile
readLong
in interface java.io.DataInput
IOExceptionUnchecked
DataInput.readLong()
public float readFloat() throws IOExceptionUnchecked
readFloat
in interface IRandomAccessFile
readFloat
in interface java.io.DataInput
IOExceptionUnchecked
DataInput.readFloat()
public double readDouble() throws IOExceptionUnchecked
readDouble
in interface IRandomAccessFile
readDouble
in interface java.io.DataInput
IOExceptionUnchecked
DataInput.readDouble()
public java.lang.String readLine() throws java.lang.UnsupportedOperationException
readLine
in interface IRandomAccessFile
readLine
in interface java.io.DataInput
java.lang.UnsupportedOperationException
DataInput.readLine()
public java.lang.String readUTF()
readUTF
in interface IRandomAccessFile
readUTF
in interface java.io.DataInput
DataInput.readUTF()
public void write(int b) throws IOExceptionUnchecked
write
in interface IOutputStream
write
in interface IRandomAccessFile
write
in interface java.io.DataOutput
IOExceptionUnchecked
DataOutput.write(int)
public void write(byte[] b) throws IOExceptionUnchecked
write
in interface IOutputStream
write
in interface IRandomAccessFile
write
in interface java.io.DataOutput
IOExceptionUnchecked
DataOutput.write(byte[])
public void write(byte[] b, int off, int len) throws IOExceptionUnchecked
write
in interface IOutputStream
write
in interface IRandomAccessFile
write
in interface java.io.DataOutput
IOExceptionUnchecked
DataOutput.write(byte[], int, int)
public void writeBoolean(boolean v) throws IOExceptionUnchecked
writeBoolean
in interface IRandomAccessFile
writeBoolean
in interface java.io.DataOutput
IOExceptionUnchecked
DataOutput.writeBoolean(boolean)
public void writeByte(int v) throws IOExceptionUnchecked
writeByte
in interface IRandomAccessFile
writeByte
in interface java.io.DataOutput
IOExceptionUnchecked
DataOutput.writeByte(int)
public void writeShort(int v) throws IOExceptionUnchecked
writeShort
in interface IRandomAccessFile
writeShort
in interface java.io.DataOutput
IOExceptionUnchecked
DataOutput.writeShort(int)
public void writeChar(int v) throws IOExceptionUnchecked
writeChar
in interface IRandomAccessFile
writeChar
in interface java.io.DataOutput
IOExceptionUnchecked
DataOutput.writeChar(int)
public void writeInt(int v) throws IOExceptionUnchecked
writeInt
in interface IRandomAccessFile
writeInt
in interface java.io.DataOutput
IOExceptionUnchecked
DataOutput.writeInt(int)
public void writeLong(long v) throws IOExceptionUnchecked
writeLong
in interface IRandomAccessFile
writeLong
in interface java.io.DataOutput
IOExceptionUnchecked
DataOutput.writeLong(long)
public void writeFloat(float v) throws IOExceptionUnchecked
writeFloat
in interface IRandomAccessFile
writeFloat
in interface java.io.DataOutput
IOExceptionUnchecked
DataOutput.writeFloat(float)
public void writeDouble(double v) throws IOExceptionUnchecked
writeDouble
in interface IRandomAccessFile
writeDouble
in interface java.io.DataOutput
IOExceptionUnchecked
DataOutput.writeDouble(double)
public void writeBytes(java.lang.String s) throws IOExceptionUnchecked
writeBytes
in interface IRandomAccessFile
writeBytes
in interface java.io.DataOutput
IOExceptionUnchecked
DataOutput.writeBytes(String)
public void writeChars(java.lang.String s) throws IOExceptionUnchecked
writeChars
in interface IRandomAccessFile
writeChars
in interface java.io.DataOutput
IOExceptionUnchecked
DataOutput.writeChars(String)
public void writeUTF(java.lang.String str) throws java.lang.UnsupportedOperationException
writeUTF
in interface IRandomAccessFile
writeUTF
in interface java.io.DataOutput
java.lang.UnsupportedOperationException
DataOutput.writeUTF(String)