public static void main(String[] args) throws Exception {
String in = args[0];
String out = args[1];
FileInputStream fis = new FileInputStream(in);
FileOutputStream fos = new FileOutputStream(out);
FileChannel inc = fis.getChannel();
FileChannel outc = fos.getChannel();
ByteBuffer bb = ByteBuffer.allocate(1024);
inc.read(bb);
show(bb, "After read");
bb.flip();
show(bb, "After flip");
outc.write(bb);
show(bb, "After write");
bb.clear();
show(bb, "After clear");
}
public static void show(ByteBuffer bb, String msg) {
System.out.println(msg " p:" bb.position() " l:" bb.limit()
" c:" bb.capacity());
文章整理:西部数码--专业提供域名注册、虚拟主机服务
http://www.west263.com
以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!



