複製自: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; }