|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectinfo.aduna.io.NioFile
public final class NioFile
File wrapper that protects against concurrent file closing events due to e.g.
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 Summary | |
|---|---|
NioFile(File file)
|
|
| Method Summary | |
|---|---|
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)
|
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
|---|
public NioFile(File file)
throws IOException
IOException| Method Detail |
|---|
public void close()
throws IOException
IOExceptionpublic 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
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||