public final class NioFile extends Object
thread interrupts
. In case the file channel that
is used by this class is closed due to such an event, it will try to reopen
the channel. The thread that causes the ClosedByInterruptException
is
not protected, assuming the interrupt is intended to end the thread's
operation.Constructor and Description |
---|
NioFile(File file) |
NioFile(File file,
String mode) |
Modifier and Type | Method and Description |
---|---|
void |
close() |
boolean |
delete()
Closed any open channels and then deletes the file.
|
void |
force(boolean metaData)
Performs a protected
FileChannel.force(boolean) call. |
File |
getFile() |
boolean |
isClosed() |
int |
read(ByteBuffer buf,
long offset)
Performs a protected
FileChannel.read(ByteBuffer, long) call. |
byte |
readByte(long offset) |
byte[] |
readBytes(long offset,
int length) |
int |
readInt(long offset) |
long |
readLong(long offset) |
long |
size()
Performs a protected
FileChannel.size() call. |
long |
transferTo(long position,
long count,
WritableByteChannel target)
Performs a protected
FileChannel.transferTo(long, long, WritableByteChannel) call. |
void |
truncate(long size)
Performs a protected
FileChannel.truncate(long) call. |
int |
write(ByteBuffer buf,
long offset)
Performs a protected
FileChannel.write(ByteBuffer, long) call. |
void |
writeByte(byte value,
long offset) |
void |
writeBytes(byte[] value,
long offset) |
void |
writeInt(int value,
long offset) |
void |
writeLong(long value,
long offset) |
public NioFile(File file) throws IOException
IOException
public NioFile(File file, String mode) throws IOException
IOException
public void close() throws IOException
IOException
public boolean isClosed()
public File getFile()
public boolean delete() throws IOException
IOException
- If there was a problem closing the open file channel.public void force(boolean metaData) throws IOException
FileChannel.force(boolean)
call.IOException
public void truncate(long size) throws IOException
FileChannel.truncate(long)
call.IOException
public long size() throws IOException
FileChannel.size()
call.IOException
public long transferTo(long position, long count, WritableByteChannel target) throws IOException
FileChannel.transferTo(long, long, WritableByteChannel)
call.IOException
public int write(ByteBuffer buf, long offset) throws IOException
FileChannel.write(ByteBuffer, long)
call.IOException
public int read(ByteBuffer buf, long offset) throws IOException
FileChannel.read(ByteBuffer, long)
call.IOException
public void writeBytes(byte[] value, long offset) throws IOException
IOException
public byte[] readBytes(long offset, int length) throws IOException
IOException
public void writeByte(byte value, long offset) throws IOException
IOException
public byte readByte(long offset) throws IOException
IOException
public void writeLong(long value, long offset) throws IOException
IOException
public long readLong(long offset) throws IOException
IOException
public void writeInt(int value, long offset) throws IOException
IOException
public int readInt(long offset) throws IOException
IOException
Copyright © 2001-2016 Aduna. All Rights Reserved.