Top Description Methods
io.netty.channel

public Interface FileRegion

extends ReferenceCounted
Known Direct Implementers
io.netty.channel.DefaultFileRegion
Imports
io.netty.util.ReferenceCounted, java.io.IOException, java.nio.channels.FileChannel, .WritableByteChannel

A region of a file that is sent via a Channel which supports zero-copy file transfer.

Upgrade your JDK / JRE

FileChannel#transferTo(long, long, WritableByteChannel) has at least four known bugs in the old versions of Sun JDK and perhaps its derived ones. Please upgrade your JDK to 1.6.0_18 or later version if you are going to use zero-copy file transfer.

Check your operating system and JDK / JRE

If your operating system (or JDK / JRE) does not support zero-copy file transfer, sending a file with FileRegion might fail or yield worse performance. For example, sending a large file doesn't work well in Windows.

Not all transports support it

Method Summary

Modifier and TypeMethod and Description
public long
count()

Returns the number of bytes to transfer.

public long
position()

Returns the offset in the file where the transfer began.

public FileRegion
retain()

Redeclares io.netty.util.ReferenceCounted.retain.

Increases the reference count by 1.
public FileRegion
retain(int increment)

Redeclares io.netty.util.ReferenceCounted.retain.

Increases the reference count by the specified increment.
public FileRegion
touch()

Redeclares io.netty.util.ReferenceCounted.touch.

Records the current access location of this object for debugging purposes.
public FileRegion
touch(Object hint)

Redeclares io.netty.util.ReferenceCounted.touch.

Records the current access location of this object with an additional arbitrary information for debugging purposes.
public long
transfered()

Deprecated Use transferred() instead.
Returns the bytes which was transferred already.
public long
transferred()

Returns the bytes which was transferred already.

public long
transferTo(WritableByteChannel
the destination of the transfer
target
,
long
the relative offset of the file where the transfer begins from. For example, 0 will make the transfer start from position()th byte and count() - 1 will make the last byte of the region transferred.
position
)

Transfers the content of this file region to the specified channel.

Inherited from io.netty.util.ReferenceCounted:
refCntreleaserelease

Method Detail

countback to summary
public long count()

Returns the number of bytes to transfer.

positionback to summary
public long position()

Returns the offset in the file where the transfer began.

retainback to summary
public FileRegion retain()

Redeclares io.netty.util.ReferenceCounted.retain.

Doc from io.netty.util.ReferenceCounted.retain.

Increases the reference count by 1.

Annotations
@Override
retainback to summary
public FileRegion retain(int increment)

Redeclares io.netty.util.ReferenceCounted.retain.

Doc from io.netty.util.ReferenceCounted.retain.

Increases the reference count by the specified increment.

Annotations
@Override
touchback to summary
public FileRegion touch()

Redeclares io.netty.util.ReferenceCounted.touch.

Doc from io.netty.util.ReferenceCounted.touch.

Records the current access location of this object for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you via ResourceLeakDetector. This method is a shortcut to touch(null).

Annotations
@Override
touchback to summary
public FileRegion touch(Object hint)

Redeclares io.netty.util.ReferenceCounted.touch.

Doc from io.netty.util.ReferenceCounted.touch.

Records the current access location of this object with an additional arbitrary information for debugging purposes. If this object is determined to be leaked, the information recorded by this operation will be provided to you via ResourceLeakDetector.

Annotations
@Override
transferedback to summary
public long transfered()

Deprecated

Use transferred() instead.

Returns the bytes which was transferred already.

Annotations
@Deprecated
transferredback to summary
public long transferred()

Returns the bytes which was transferred already.

transferToback to summary
public long transferTo(WritableByteChannel target, long position) throws IOException

Transfers the content of this file region to the specified channel.

Parameters
target:WritableByteChannel

the destination of the transfer

position:long

the relative offset of the file where the transfer begins from. For example, 0 will make the transfer start from position()th byte and count() - 1 will make the last byte of the region transferred.