public class FileTransfer extends Object implements WritableMessage
FileChannel.transferTo(long, long, java.nio.channels.WritableByteChannel)
for use with Grizzly 2.0 AsyncQueueWriter
.Constructor and Description |
---|
FileTransfer(File f)
Constructs a new
FileTransfer instance backed by the specified
File . |
FileTransfer(File f,
long pos,
long len)
Constructs a new
FileTransfer instance backed by the specified
File . |
Modifier and Type | Method and Description |
---|---|
boolean |
hasRemaining()
Return
true if this message has data remaining to be
written. |
boolean |
isExternal()
Returns true if the message represents an external resource
(for example
FileTransfer ),
which is not loaded in memory. |
boolean |
release()
Perform message specific actions to release resources held by the
entity backing this
WritableMessage . |
int |
remaining()
Return the number of bytes remaining to be written.
|
long |
writeTo(WritableByteChannel c)
Transfers the File backing this
FileTransfer to the specified
WritableByteChannel . |
public FileTransfer(File f)
FileTransfer
instance backed by the specified
File
. This simply calls this(f, 0, f.length)
.f
- the File
to transfer.NullPointerException
- if f is null.FileTransfer(java.io.File, long, long)
public FileTransfer(File f, long pos, long len)
FileTransfer
instance backed by the specified
File
. The content to transfer will begin at the specified offset,
pos
with the total transfer length being specified by
len
.f
- the File
to transfer.pos
- the offset within the File to start the transfer.len
- the total number of bytes to transfer.IllegalArgumentException
- if f
is null, does not exist, is
not readable, or is a directory.IllegalArgumentException
- if pos
or len
are negative.IllegalArgumentException
- if len exceeds the number of bytes that
may be transferred based on the provided offset and file length.public long writeTo(WritableByteChannel c) throws IOException
FileTransfer
to the specified
WritableByteChannel
.c
- the WritableByteChannel
IOException
public boolean hasRemaining()
true
if this message has data remaining to be
written.hasRemaining
in interface WritableMessage
true
if this message has data remaining to
be written.public int remaining()
remaining
in interface WritableMessage
public boolean release()
WritableMessage
.release
in interface WritableMessage
public boolean isExternal()
FileTransfer
),
which is not loaded in memory.
False, if the message is
located in memory (like Buffer
).isExternal
in interface WritableMessage
Copyright © 2014 Oracle Corporation. All rights reserved.