复制自:http://www.cnblogs.com/youngKen/p/4921092.htmlhtml
java.nio.channels.FileChannel封装了一个文件通道和一个FileChannel对象,这个FileChannel对象提供了读写文件的链接。java
//源码
public interface Channel extends Closeable { boolean isOpen(); void close() throws IOException; }
由于通道接口都是扩展AutoCloseable接口,如是是在带资源的try代码中建立他们,那么全部通道将会自动关闭。测试
//源码
public interface ReadableByteChannel extends Channel {
int read(ByteBuffer var1) throws IOException; }
c、WriteableByteChannel接口:code
//源码
public interface WritableByteChannel extends Channel { int write(ByteBuffer var1) throws IOException; }
d、ByteChannel接口:htm
public interface ByteChannel extends ReadableByteChannel, WritableByteChannel { }
e、ScatteringByteChannel接口:对象
public interface ScatteringByteChannel extends ReadableByteChannel { long read(ByteBuffer[] var1) throws IOException; long read(ByteBuffer[] var1, int var2, int var3) throws IOException; }
f、GatheringByteChannel接口:blog
public interface GatheringByteChannel extends WritableByteChannel { long write(ByteBuffer[] var1) throws IOException; long write(ByteBuffer[] var1, int var2, int var3) throws IOException; }