Reusable Java library of general tools with minimal external dependencies.
For questions or support, please contact us:
Email: support@aoindustries.com
Phone: 1-800-519-9541
Phone: +1-251-607-9556
Web: https://www.aoindustries.com/contact
public class RandomAccessFileBuffer extends AbstractPersistentBuffer
RandomAccessFile for persistence. Obtains a shared lock
on the channel for read-only mode or an exclusive lock for write mode. The
lock is held until the buffer is closed.protectionLevel| Constructor and Description |
|---|
RandomAccessFileBuffer()
Creates a read-write buffer backed by a temporary file.
|
RandomAccessFileBuffer(File file)
Creates a read-write buffer with
BARRIER protection level. |
RandomAccessFileBuffer(File file,
ProtectionLevel protectionLevel)
Creates a buffer.
|
RandomAccessFileBuffer(RandomAccessFile raf,
ProtectionLevel protectionLevel)
Creates a buffer using the provided
RandomAccessFile. |
RandomAccessFileBuffer(String name)
Creates a read-write buffer with
BARRIER protection level. |
RandomAccessFileBuffer(String name,
ProtectionLevel protectionLevel)
Creates a buffer.
|
| Modifier and Type | Method and Description |
|---|---|
void |
barrier(boolean force)
There is not currently a way to provide a barrier without using
force. |
long |
capacity()
Gets the capacity of this buffer.
|
void |
close()
Closes this buffer.
|
void |
ensureZeros(long position,
long len)
Ensures that all values from the position for the provided length
are zeros.
|
protected void |
finalize() |
byte |
get(long position)
Gets a single byte from the buffer.
|
int |
getSome(long position,
byte[] buff,
int off,
int len)
Reads to the provided
byte[], may read fewer than len
bytes, but will always read at least one byte. |
boolean |
isClosed()
Checks if this buffer is closed.
|
void |
put(long position,
byte value)
Puts a single byte in the buffer.
|
void |
put(long position,
byte[] buff,
int off,
int len)
Writes the bytes to the provided position.
|
void |
setCapacity(long newLength)
Sets the capacity of this buffer.
|
get, getBoolean, getInputStream, getInt, getLong, getOutputStream, getProtectionLevel, putInt, putLongpublic RandomAccessFileBuffer()
throws IOException
NONE. The temporary file will be deleted when this
buffer is closed or on JVM shutdown.IOExceptionpublic RandomAccessFileBuffer(String name) throws IOException
BARRIER protection level.IOExceptionpublic RandomAccessFileBuffer(String name, ProtectionLevel protectionLevel) throws IOException
IOExceptionpublic RandomAccessFileBuffer(File file) throws IOException
BARRIER protection level.IOExceptionpublic RandomAccessFileBuffer(File file, ProtectionLevel protectionLevel) throws IOException
IOExceptionpublic RandomAccessFileBuffer(RandomAccessFile raf, ProtectionLevel protectionLevel) throws IOException
RandomAccessFile.IOExceptionpublic boolean isClosed()
PersistentBufferprotected void finalize()
throws Throwable
public void close()
throws IOException
PersistentBufferIOExceptionpublic long capacity()
throws IOException
PersistentBufferIOExceptionpublic void setCapacity(long newLength)
throws IOException
PersistentBufferbarrier(true), depending on implementation. This
should be considered an expensive operation.IOExceptionpublic int getSome(long position,
byte[] buff,
int off,
int len)
throws IOException
PersistentBufferbyte[], may read fewer than len
bytes, but will always read at least one byte. Blocks if no data is
available.IOExceptionpublic byte get(long position)
throws IOException
get in interface PersistentBufferget in class AbstractPersistentBufferIOExceptionAbstractPersistentBuffer.get(long, byte[], int, int)public void ensureZeros(long position,
long len)
throws IOException
PersistentBufferIOExceptionpublic void put(long position,
byte value)
throws IOException
put in interface PersistentBufferput in class AbstractPersistentBufferIOExceptionPersistentBuffer.put(long, byte[], int, int)public void put(long position,
byte[] buff,
int off,
int len)
throws IOException
PersistentBufferIOExceptionpublic void barrier(boolean force)
throws IOException
force.
This just uses force for each case.IOExceptionPersistentBuffer.getProtectionLevel()Copyright © 2000–2016 AO Industries, Inc.. All rights reserved.