public final class NioFile extends Object implements Closeable
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
IOExceptionpublic NioFile(File file, String mode) throws IOException
IOExceptionpublic void close()
throws IOException
close in interface Closeableclose in interface AutoCloseableIOExceptionpublic 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.IOExceptionpublic void truncate(long size)
throws IOException
FileChannel.truncate(long) call.IOExceptionpublic long size()
throws IOException
FileChannel.size() call.IOExceptionpublic long transferTo(long position,
long count,
WritableByteChannel target)
throws IOException
FileChannel.transferTo(long, long, WritableByteChannel) call.IOExceptionpublic int write(ByteBuffer buf, long offset) throws IOException
FileChannel.write(ByteBuffer, long) call.IOExceptionpublic int read(ByteBuffer buf, long offset) throws IOException
FileChannel.read(ByteBuffer, long) call.IOExceptionpublic void writeBytes(byte[] value,
long offset)
throws IOException
IOExceptionpublic byte[] readBytes(long offset,
int length)
throws IOException
IOExceptionpublic void writeByte(byte value,
long offset)
throws IOException
IOExceptionpublic byte readByte(long offset)
throws IOException
IOExceptionpublic void writeLong(long value,
long offset)
throws IOException
IOExceptionpublic long readLong(long offset)
throws IOException
IOExceptionpublic void writeInt(int value,
long offset)
throws IOException
IOExceptionpublic int readInt(long offset)
throws IOException
IOExceptionCopyright © 2015-2018 Eclipse Foundation. All Rights Reserved.