public class InMemoryRandomAccessFile extends RandomAccessFile
allFiles, BIG_ENDIAN, bigEndian, buffer, bufferStart, dataEnd, dataSize, debugAccess, debugLeaks, defaultBufferSize, endOfFile, file, fileChannel, filePosition, LITTLE_ENDIAN, location, openFiles, readonly, showOpen, showRead
Constructor and Description |
---|
InMemoryRandomAccessFile(java.lang.String name,
byte[] data)
A RandomAccessFile stored entirely in memory as a byte array.
|
Modifier and Type | Method and Description |
---|---|
long |
length()
Get the length of the file.
|
protected int |
read_(long pos,
byte[] b,
int offset,
int len)
Read directly from file, without going through the buffer.
|
long |
readToByteChannel(java.nio.channels.WritableByteChannel dest,
long offset,
long nbytes)
Read
nbytes bytes, at the specified file offset, send to a WritableByteChannel. |
void |
setBufferSize(int bufferSize)
Set the buffer size.
|
acquire, acquire, close, eject, enableDefaultGlobalFileCache, flush, getAllFiles, getBufferSize, getDebugLeaks, getDebugNbytes, getDebugNseeks, getFilePointer, getGlobalFileCache, getLastModified, getLocation, getMaxOpenFileCount, getOpenFileCount, getOpenFiles, getRandomAccessFile, isAtEndOfFile, order, order, reacquire, read, read, read, readBoolean, readBuffer, readByte, readBytes, readBytes, readChar, readDouble, readDouble, readFloat, readFloat, readFully, readFully, readInt, readInt, readIntUnbuffered, readLine, readLong, readLong, readShort, readShort, readString, readStringMax, readUnsignedByte, readUnsignedShort, readUTF, release, searchForward, seek, setDebugAccess, setDebugLeaks, setExtendMode, setFileCache, setGlobalFileCache, setMinLength, shutdown, skipBytes, skipBytes, toString, unread, write, write, write, writeBoolean, writeBoolean, writeByte, writeBytes, writeBytes, writeBytes, writeChar, writeChar, writeChars, writeDouble, writeDouble, writeFloat, writeFloat, writeInt, writeInt, writeLong, writeLong, writeShort, writeShort, writeUTF
public InMemoryRandomAccessFile(java.lang.String name, byte[] data)
name
- used as the locationdata
- the complete data filepublic long length()
RandomAccessFile
length
in class RandomAccessFile
public void setBufferSize(int bufferSize)
RandomAccessFile
setBufferSize
in class RandomAccessFile
bufferSize
- length in bytesprotected int read_(long pos, byte[] b, int offset, int len) throws java.io.IOException
RandomAccessFile
read_
in class RandomAccessFile
pos
- start here in the fileb
- put data into this bufferoffset
- buffer offsetlen
- this number of bytesjava.io.IOException
- on io errorpublic long readToByteChannel(java.nio.channels.WritableByteChannel dest, long offset, long nbytes) throws java.io.IOException
RandomAccessFile
nbytes
bytes, at the specified file offset, send to a WritableByteChannel.
This will block until all bytes are read.
This uses the underlying file channel directly, bypassing all user buffers.readToByteChannel
in class RandomAccessFile
dest
- write to this WritableByteChannel.offset
- the offset in the file where copying will start.nbytes
- the number of bytes to read.java.io.IOException
- if an I/O error occurs.