package com.gochinatv.cdn.api.basic.nio;

import java.io.FileOutputStream;
import java.nio.channels.FileChannel;


/**
 * http://ifeve.com/file-channel/
 * @author jacktomcat
 *
 */
public class FileChannelTest {
   
	
	/**
	 * 在使用FileChannel之前，必须先打开它。但是，我们无法直接打开一个FileChannel，
	 * 需要通过使用一个InputStream、OutputStream或RandomAccessFile来获取一个FileChannel实例。
	 * 下面是通过RandomAccessFile打开FileChannel的示例：
	 * @param args
	 * @throws Exception
	 */
	public static void main(String[] args) throws Exception {
		FileChannel channel = new FileOutputStream("d:/").getChannel();
		
		
	}
}

@@ -56,28 +56,90 @@
 .io.File
-OutputStream
+InputStream;%0D%0Aimport java.io.FileOutputStream;%0D%0Aimport java.nio.ByteBuffer
 ;%0D%0Aimpor
@@ -216,16 +216,135 @@
 annel/%0D%0A
+ * %0D%0A * http://blog.csdn.net/wangxy799/article/details/50897061%0D%0A * %0D%0A * http://www.tuicool.com/articles/RziquaY%0D%0A * %0D%0A
  * @auth
@@ -694,16 +694,18 @@
 on %7B%0D%0A%09%09
+//
 FileChan
@@ -763,16 +763,358 @@
 l();%0D%0A%09%09
+//RandomAccessFile aFile = new RandomAccessFile(%22data/nio-data.txt%22, %22rw%22);%0D%0A%09%09%0D%0A%09%09%0D%0A%09%09FileChannel inputChannel = new FileInputStream(%22d:/channel.txt%22).getChannel();%0D%0A%09%09ByteBuffer buffer = ByteBuffer.allocate(1024);%0D%0A%09%09int read = inputChannel.read(buffer);//%E8%AF%BB%E5%8F%96%E7%9A%84%E6%96%87%E4%BB%B6%E5%AD%97%E8%8A%82%E6%95%B0%0D%0A%09%09byte%5B%5D array = buffer.array();%0D%0A%09%09System.out.println(new String(array));
 %0D%0A%09%09%0D%0A%09%7D

add fileChannel support