public class MemFileChannel extends FileChannel
newChannel()
methods to construct an instance of this class.
In order to use this class with a Database, you must use the DatabaseBuilder
to open/create the Database instance, passing an instance
of this class to the DatabaseBuilder.setChannel(java.nio.channels.FileChannel)
method.
Implementation note: this class is optimized for use with Database
.
Therefore not all methods may be implemented and individual read/write
operations are only supported within page boundaries.
FileChannel.MapMode
Modifier and Type | Field and Description |
---|---|
static String |
RO_CHANNEL_MODE
read-only channel access mode
|
static String |
RW_CHANNEL_MODE
read/write channel access mode
|
Modifier and Type | Method and Description |
---|---|
void |
force(boolean metaData) |
FileLock |
lock(long position,
long size,
boolean shared) |
MappedByteBuffer |
map(FileChannel.MapMode mode,
long position,
long size) |
static MemFileChannel |
newChannel()
Creates a new read/write, empty MemFileChannel.
|
static MemFileChannel |
newChannel(File file)
Creates a new read/write MemFileChannel containing the contents of the
given File.
|
static MemFileChannel |
newChannel(File file,
String mode)
Creates a new MemFileChannel containing the contents of the
given File with the given mode (for mode details see
RandomAccessFile.RandomAccessFile(File,String) ). |
static MemFileChannel |
newChannel(InputStream in)
Creates a new read/write MemFileChannel containing the contents of the
given InputStream.
|
static MemFileChannel |
newChannel(InputStream in,
String mode)
Creates a new MemFileChannel containing the contents of the
given InputStream with the given mode (for mode details see
RandomAccessFile.RandomAccessFile(File,String) ). |
static MemFileChannel |
newChannel(Path file)
Creates a new read/write MemFileChannel containing the contents of the
given Path.
|
static MemFileChannel |
newChannel(Path file,
OpenOption... opts)
Creates a new MemFileChannel containing the contents of the
given Path with the given mode (for mode details see
RandomAccessFile.RandomAccessFile(File,String) ). |
static MemFileChannel |
newChannel(ReadableByteChannel in)
Creates a new read/write MemFileChannel containing the contents of the
given ReadableByteChannel.
|
static MemFileChannel |
newChannel(ReadableByteChannel in,
String mode)
Creates a new MemFileChannel containing the contents of the
given ReadableByteChannel with the given mode (for mode details see
RandomAccessFile.RandomAccessFile(File,String) ). |
long |
position() |
FileChannel |
position(long newPosition) |
int |
read(ByteBuffer dst) |
long |
read(ByteBuffer[] dsts,
int offset,
int length) |
int |
read(ByteBuffer dst,
long position) |
long |
size() |
long |
transferFrom(ReadableByteChannel src,
long position,
long count) |
long |
transferTo(long position,
long count,
OutputStream dst)
Convenience method for writing the selected portion of this channel to
the given destination stream.
|
long |
transferTo(long position,
long count,
WritableByteChannel dst) |
long |
transferTo(OutputStream dst)
Convenience method for writing the entire contents of this channel to the
given destination stream.
|
long |
transferTo(WritableByteChannel dst)
Convenience method for writing the entire contents of this channel to the
given destination channel.
|
FileChannel |
truncate(long newSize) |
FileLock |
tryLock(long position,
long size,
boolean shared) |
int |
write(ByteBuffer src) |
long |
write(ByteBuffer[] srcs,
int offset,
int length) |
int |
write(ByteBuffer src,
long position) |
close, isOpen
public static final String RO_CHANNEL_MODE
public static final String RW_CHANNEL_MODE
public static MemFileChannel newChannel()
public static MemFileChannel newChannel(File file) throws IOException
IOException
public static MemFileChannel newChannel(File file, String mode) throws IOException
RandomAccessFile.RandomAccessFile(File,String)
). Note,
modifications to the returned channel will not affect the original
File source.IOException
public static MemFileChannel newChannel(Path file, OpenOption... opts) throws IOException
RandomAccessFile.RandomAccessFile(File,String)
). Note,
modifications to the returned channel will not affect the original
File source.IOException
public static MemFileChannel newChannel(Path file) throws IOException
IOException
public static MemFileChannel newChannel(InputStream in) throws IOException
IOException
public static MemFileChannel newChannel(InputStream in, String mode) throws IOException
RandomAccessFile.RandomAccessFile(File,String)
).IOException
public static MemFileChannel newChannel(ReadableByteChannel in) throws IOException
IOException
public static MemFileChannel newChannel(ReadableByteChannel in, String mode) throws IOException
RandomAccessFile.RandomAccessFile(File,String)
).IOException
public int read(ByteBuffer dst) throws IOException
read
in interface ReadableByteChannel
read
in interface SeekableByteChannel
read
in class FileChannel
IOException
public int read(ByteBuffer dst, long position) throws IOException
read
in class FileChannel
IOException
public int write(ByteBuffer src) throws IOException
write
in interface SeekableByteChannel
write
in interface WritableByteChannel
write
in class FileChannel
IOException
public int write(ByteBuffer src, long position) throws IOException
write
in class FileChannel
IOException
public long position() throws IOException
position
in interface SeekableByteChannel
position
in class FileChannel
IOException
public FileChannel position(long newPosition) throws IOException
position
in interface SeekableByteChannel
position
in class FileChannel
IOException
public long size() throws IOException
size
in interface SeekableByteChannel
size
in class FileChannel
IOException
public FileChannel truncate(long newSize) throws IOException
truncate
in interface SeekableByteChannel
truncate
in class FileChannel
IOException
public void force(boolean metaData) throws IOException
force
in class FileChannel
IOException
public long transferTo(WritableByteChannel dst) throws IOException
IOException
transferTo(long,long,WritableByteChannel)
public long transferTo(long position, long count, WritableByteChannel dst) throws IOException
transferTo
in class FileChannel
IOException
public long transferTo(OutputStream dst) throws IOException
IOException
transferTo(long,long,WritableByteChannel)
public long transferTo(long position, long count, OutputStream dst) throws IOException
IOException
transferTo(long,long,WritableByteChannel)
public long transferFrom(ReadableByteChannel src, long position, long count) throws IOException
transferFrom
in class FileChannel
IOException
public long write(ByteBuffer[] srcs, int offset, int length) throws IOException
write
in interface GatheringByteChannel
write
in class FileChannel
IOException
public long read(ByteBuffer[] dsts, int offset, int length) throws IOException
read
in interface ScatteringByteChannel
read
in class FileChannel
IOException
public MappedByteBuffer map(FileChannel.MapMode mode, long position, long size) throws IOException
map
in class FileChannel
IOException
public FileLock lock(long position, long size, boolean shared) throws IOException
lock
in class FileChannel
IOException
public FileLock tryLock(long position, long size, boolean shared) throws IOException
tryLock
in class FileChannel
IOException
Copyright © 2005–2024 OpenHMS. All rights reserved.