NIO的transferTo方法

  大家好!我最近在做NIO,为什么我使用NIO的transferTo方法貌似数据没有加载到管道
求大神指点

package com.etwin.opps.policy.mvc;

import java.io.RandomAccessFile;
import java.nio.ByteBuffer;
import java.nio.channels.FileChannel;

import org.slf4j.Logger;

import com.modules.util.Log;

public class NioChannelControllerTest {
private final static Logger logger=Log.get();

/**
* @param args
*/
public static void main(String[] args) {
logger.info("Start NioChannelControllerTest==");
try {
RandomAccessFile randomFile=new RandomAccessFile("E://om_seat20140628.txt", "rw");
//开通通道
FileChannel fileChannel=randomFile.getChannel();
RandomAccessFile randomAccFile=new RandomAccessFile("E://aa.txt","rw");
//开通通道
FileChannel fileChan=randomAccFile.getChannel();
long count=0;
fileChan.transferTo(count,fileChannel.size(), fileChannel);
            ByteBuffer byteBu=ByteBuffer.allocate(1024);
            int num=fileChan.read(byteBu);
            while(num!=-1){
            fileChan.write(byteBu);
            }

} catch (Exception e) {
            logger.info(e.getMessage());
e.printStackTrace();
}

}

}

你可能感兴趣的:(NIO的transferTo方法)