nio filechannel
来源:互联网 发布:mac魔兽世界设置 编辑:程序博客网 时间:2024/05/24 02:33
nio fileChannel使用:
try(FileInputStream in=new FileInputStream("D:/soft/Evernote_6.5.4.4720.exe"); FileOutputStream out=new FileOutputStream("E:/Evernote_6.5.4.4720.exe"); FileChannel fcin=in.getChannel(); FileChannel fcou=out.getChannel()) { fcou.transferFrom(fcin,0,fcin.size()); //使用transferFrom 直接将 fcin的数据输出到fc }
try(FileInputStream in=new FileInputStream("D:/soft/Evernote_6.5.4.4720.exe"); FileOutputStream out=new FileOutputStream("E:/Evernote_6.5.4.4720.exe"); FileChannel fcin=in.getChannel(); FileChannel fcou=out.getChannel()) { fcin.transferTo(0,fcin.size(),fcou); //使用transferTo 直接将 fcin的数据输出到fc }
使用ByteBuffer写法:
try(FileInputStream in=new FileInputStream("D:/soft/Evernote_6.5.4.4720.exe"); FileOutputStream out=new FileOutputStream("E:/Evernote_6.5.4.4720.exe"); FileChannel fcin=in.getChannel(); FileChannel fcou=out.getChannel()) { ByteBuffer bf=ByteBuffer.allocate(1024); while(fcin.read(bf) != -1) { bf.flip(); while(bf.hasRemaining()){ fcou.write(bf); } bf.clear(); } }
阅读全文
0 0
- NIO - FileChannel
- NIO - FileChannel
- NIO - FileChannel
- nio filechannel
- Java NIO FileChannel
- JAVA NIO之FileChannel
- Java NIO(8-FileChannel)
- Java nio 之 FileChannel
- Java NIO FileChannel
- Java NIO FileChannel
- java nio(二)FileChannel
- Java NIO -- FileChannel
- Java NIO (七) FileChannel
- Java NIO FileChannel
- java8 NIO FileChannel例
- Java NIO FileChannel
- java nio 之FileChannel
- NIO(3) FileChannel
- POJ
- 用python对两个文本进行相同项筛选
- 分享几条比较好的关于聊天机器人的链接
- 【二叉树】层次遍历二叉树以及判断一棵树是否是完全二叉树
- Android Lambda表达式
- nio filechannel
- selenium之 chromedriver与chrome版本映射表(更新至v2.31)
- 单词匹配(北大ACM)
- 大数据量高并发的数据库优化
- hdu 6054-Is Derek lying?
- Unity_简单工厂设计模式_029
- html格式化,htm代码美化
- 多校6050 Funny Function
- 【华为机试】字符串合并处理