public class DefaultFileRegion extends AbstractReferenceCounted implements FileRegion
FileRegion implementation which transfer data from a FileChannel or File.
Be aware that the FileChannel will be automatically closed once AbstractReferenceCounted.refCnt() returns
0.| 构造器和说明 |
|---|
DefaultFileRegion(java.nio.channels.FileChannel fileChannel,
long position,
long count)
Create a new instance
|
DefaultFileRegion(java.io.File file,
long position,
long count)
Create a new instance using the given
File. |
| 限定符和类型 | 方法和说明 |
|---|---|
long |
count()
Returns the number of bytes to transfer.
|
protected void |
deallocate()
Called once
AbstractReferenceCounted.refCnt() is equals 0. |
boolean |
isOpen()
Returns
true if the FileRegion has a open file-descriptor |
void |
open()
Explicitly open the underlying file-descriptor if not done yet.
|
long |
position()
Returns the offset in the file where the transfer began.
|
FileRegion |
retain()
Increases the reference count by
1. |
FileRegion |
retain(int increment)
Increases the reference count by the specified
increment. |
FileRegion |
touch()
Records the current access location of this object for debugging purposes.
|
FileRegion |
touch(java.lang.Object hint)
Records the current access location of this object with an additional arbitrary information for debugging
purposes.
|
long |
transfered()
已过时。
|
long |
transferred()
Returns the bytes which was transferred already.
|
long |
transferTo(java.nio.channels.WritableByteChannel target,
long position)
Transfers the content of this file region to the specified channel.
|
refCnt, release, release, setRefCntclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitrefCnt, release, releasepublic DefaultFileRegion(java.nio.channels.FileChannel fileChannel,
long position,
long count)
fileChannel - the FileChannel which should be transferredposition - the position from which the transfer should startcount - the number of bytes to transferpublic DefaultFileRegion(java.io.File file,
long position,
long count)
File. The File will be opened lazily or
explicitly via open().file - the File which should be transferredposition - the position from which the transfer should startcount - the number of bytes to transferpublic boolean isOpen()
true if the FileRegion has a open file-descriptorpublic void open()
throws java.io.IOException
java.io.IOExceptionpublic long position()
FileRegionposition 在接口中 FileRegionpublic long count()
FileRegioncount 在接口中 FileRegion@Deprecated public long transfered()
FileRegiontransfered 在接口中 FileRegionpublic long transferred()
FileRegiontransferred 在接口中 FileRegionpublic long transferTo(java.nio.channels.WritableByteChannel target,
long position)
throws java.io.IOException
FileRegiontransferTo 在接口中 FileRegiontarget - the destination of the transferposition - the relative offset of the file where the transfer
begins from. For example, 0 will make the
transfer start from FileRegion.position()th byte and
FileRegion.count() - 1 will make the last
byte of the region transferred.java.io.IOExceptionprotected void deallocate()
AbstractReferenceCountedAbstractReferenceCounted.refCnt() is equals 0.deallocate 在类中 AbstractReferenceCountedpublic FileRegion retain()
ReferenceCounted1.retain 在接口中 FileRegionretain 在接口中 ReferenceCountedretain 在类中 AbstractReferenceCountedpublic FileRegion retain(int increment)
ReferenceCountedincrement.retain 在接口中 FileRegionretain 在接口中 ReferenceCountedretain 在类中 AbstractReferenceCountedpublic FileRegion touch()
ReferenceCountedResourceLeakDetector. This method is a shortcut to touch(null).touch 在接口中 FileRegiontouch 在接口中 ReferenceCountedtouch 在类中 AbstractReferenceCountedpublic FileRegion touch(java.lang.Object hint)
ReferenceCountedResourceLeakDetector.touch 在接口中 FileRegiontouch 在接口中 ReferenceCounted