码迷,mamicode.com
首页 > 其他好文 > 详细

I/O:FileChannel

时间:2019-03-15 17:29:23      阅读:144      评论:0      收藏:0      [点我收藏+]

标签:区域   meta   target   文件中   class   share   ann   tab   存储   

abstract void force(boolean metaData)                                              :强制将所有对此通道的文件更新写入包含该文件的存储设备中。
abstract MappedByteBuffer map(FileChannel.MapMode mode, long position, long size)  :将此通道的文件区域直接映射到内存中。
abstract long position()                                                           :返回此通道的文件位置。
abstract FileChannel position(long newPosition)                                    :设置此通道的文件位置。
abstract long size()                                                               :返回此通道的文件的当前大小。
abstract FileChannel truncate(long size)                                           :将此通道的文件截取为给定大小。

FileLock lock()                                                     :获取对此通道的文件的独占锁定。
FileLock tryLock()                                                  :试图获取对此通道的文件的独占锁定。
abstract FileLock tryLock(long position, long size, boolean shared) :试图获取对此通道的文件给定区域的锁定。
abstract FileLock lock(long position, long size, boolean shared)    :获取此通道的文件给定区域上的锁定。


abstract int read(ByteBuffer dst)                             :将字节序列从此通道读入给定的缓冲区。
long read(ByteBuffer[] dsts)                                  :将字节序列从此通道读入给定的缓冲区。
abstract long read(ByteBuffer[] dsts, int offset, int length) :将字节序列从此通道读入给定缓冲区的子序列中。
abstract int read(ByteBuffer dst, long position)              :从给定的文件位置开始,从此通道读取字节序列,并写入给定的缓冲区。


abstract int write(ByteBuffer src)                             :将字节序列从给定的缓冲区写入此通道。
long write(ByteBuffer[] srcs)                                  :将字节序列从给定的缓冲区写入此通道。
abstract long write(ByteBuffer[] srcs, int offset, int length) :将字节序列从给定缓冲区的子序列写入此通道。
abstract int write(ByteBuffer src, long position)              :从给定的文件位置开始,将字节序列从给定缓冲区写入此通道。


abstract long transferFrom(ReadableByteChannel src, long position, long count)  :将字节从给定的可读取字节通道传输到此通道的文件中。
abstract long transferTo(long position, long count, WritableByteChannel target) :将字节从此通道的文件传输到给定的可写入字节通道。

 

I/O:FileChannel

标签:区域   meta   target   文件中   class   share   ann   tab   存储   

原文地址:https://www.cnblogs.com/junjie2019/p/10538229.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!