|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
public interface IRandomAccessDataBuffer
Method Summary | |
---|---|
void |
close()
|
void |
delete()
|
java.nio.channels.ByteChannel |
getChannel()
|
long |
getCursorOffset()
|
long |
length()
|
void |
read(byte[] b,
int off,
int len)
|
void |
resetToEnd()
|
void |
resetToStart()
|
void |
seek(long pos)
|
void |
setLength(long newLength)
|
long |
skip(long n)
|
long |
transferFrom(java.nio.channels.ReadableByteChannel src,
long position,
long count)
Transfers bytes into this channel's file from the given readable byte channel. |
long |
transferTo(long position,
long count,
java.nio.channels.WritableByteChannel target)
Transfers bytes from this channel's file to the given writable byte channel. |
Methods inherited from interface java.io.DataInput |
---|
readBoolean, readByte, readChar, readDouble, readFloat, readFully, readFully, readInt, readLine, readLong, readShort, readUnsignedByte, readUnsignedShort, readUTF, skipBytes |
Methods inherited from interface java.io.DataOutput |
---|
write, write, write, writeBoolean, writeByte, writeBytes, writeChar, writeChars, writeDouble, writeFloat, writeInt, writeLong, writeShort, writeUTF |
Method Detail |
---|
void seek(long pos) throws java.io.IOException
java.io.IOException
long length() throws java.io.IOException
java.io.IOException
void setLength(long newLength) throws java.io.IOException
java.io.IOException
long getCursorOffset() throws java.io.IOException
java.io.IOException
java.nio.channels.ByteChannel getChannel()
void close() throws java.io.IOException
java.io.IOException
void delete() throws java.io.IOException
java.io.IOException
long transferTo(long position, long count, java.nio.channels.WritableByteChannel target) throws java.io.IOException
An attempt is made to read up to count bytes starting at the given position in this channel's file and write them to the target channel. An invocation of this method may or may not transfer all of the requested bytes; whether or not it does so depends upon the natures and states of the channels. Fewer than the requested number of bytes are transferred if this channel's file contains fewer than count bytes starting at the given position, or if the target channel is non-blocking and it has fewer than count bytes free in its output buffer.
This method does not modify this channel's position. If the given position is greater than the file's current size then no bytes are transferred. If the target channel has a position then bytes are written starting at that position and then the position is incremented by the number of bytes written.
This method is potentially much more efficient than a simple loop that reads from this channel and writes to the target channel. Many operating systems can transfer bytes directly from the filesystem cache to the target channel without actually copying them.
position
- The position within the file at which the transfer is to begin;
must be non-negativecount
- The maximum number of bytes to be transferred; must be
non-negativetarget
- The target channel
java.lang.IllegalArgumentException
- If the preconditions on the parameters do not hold
java.nio.channels.NonReadableChannelException
- If this channel was not opened for reading
java.nio.channels.NonWritableChannelException
- If the target channel was not opened for writing
java.nio.channels.ClosedChannelException
- If either this channel or the target channel is closed
java.nio.channels.AsynchronousCloseException
- If another thread closes either channel
while the transfer is in progress
java.nio.channels.ClosedByInterruptException
- If another thread interrupts the current thread while the
transfer is in progress, thereby closing both channels and
setting the current thread's interrupt status
java.io.IOException
- If some other I/O error occurslong transferFrom(java.nio.channels.ReadableByteChannel src, long position, long count) throws java.io.IOException
An attempt is made to read up to count bytes from the source channel and write them to this channel's file starting at the given position. An invocation of this method may or may not transfer all of the requested bytes; whether or not it does so depends upon the natures and states of the channels. Fewer than the requested number of bytes will be transferred if the source channel has fewer than count bytes remaining, or if the source channel is non-blocking and has fewer than count bytes immediately available in its input buffer.
This method does not modify this channel's position. If the given position is greater than the file's current size then no bytes are transferred. If the source channel has a position then bytes are read starting at that position and then the position is incremented by the number of bytes read.
This method is potentially much more efficient than a simple loop that reads from the source channel and writes to this channel. Many operating systems can transfer bytes directly from the source channel into the filesystem cache without actually copying them.
src
- The source channelposition
- The position within the file at which the transfer is to begin;
must be non-negativecount
- The maximum number of bytes to be transferred; must be
non-negative
java.lang.IllegalArgumentException
- If the preconditions on the parameters do not hold
java.nio.channels.NonReadableChannelException
- If the source channel was not opened for reading
java.nio.channels.NonWritableChannelException
- If this channel was not opened for writing
java.nio.channels.ClosedChannelException
- If either this channel or the source channel is closed
java.nio.channels.AsynchronousCloseException
- If another thread closes either channel
while the transfer is in progress
java.nio.channels.ClosedByInterruptException
- If another thread interrupts the current thread while the
transfer is in progress, thereby closing both channels and
setting the current thread's interrupt status
java.io.IOException
- If some other I/O error occursvoid resetToStart() throws java.io.IOException
java.io.IOException
void resetToEnd() throws java.io.IOException
java.io.IOException
void read(byte[] b, int off, int len) throws java.io.IOException
java.io.IOException
long skip(long n) throws java.io.IOException
java.io.IOException
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |