java8 NIO FileChannel例
来源:互联网 发布:数据新闻比赛官网 编辑:程序博客网 时间:2024/05/20 17:25
package com.kd.nio;import java.io.File;import java.io.FileInputStream;import java.io.FileOutputStream;import java.nio.ByteBuffer;import java.nio.channels.FileChannel;public class FileChannelTest {@SuppressWarnings("resource")public static void main(String[] args) throws Exception{FileInputStream fileInputStream = new FileInputStream("f:"+ File.separator +"15000352101265508578.pdf");FileOutputStream fileOutputStream = new FileOutputStream("f:" + File.separator + "test.pdf"); FileChannel inChannel = fileInputStream.getChannel();FileChannel outChannel= fileOutputStream.getChannel();ByteBuffer byteBuffer = ByteBuffer.allocate(1024); int read = inChannel.read(byteBuffer);while(read!=-1){byteBuffer.flip();outChannel.write(byteBuffer);byteBuffer.clear();read = inChannel.read(byteBuffer);}inChannel.close();outChannel.close();}}
0 0
- java8 NIO FileChannel例
- 【Java8源码分析】NIO包-FileChannel
- 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
- Java NIO FileChannel
- java nio 之FileChannel
- eclipse中tomcat启动不了问题
- Windows下 Python3.5 运行环境的搭建
- JAVA Calendar详解
- ViewDragHelper详解- 可拖动的view
- 1045 access denied for user ’root’@’localhost’ using password yes
- java8 NIO FileChannel例
- 如何用几何画板把圆奇数等分
- 命令模式(Command) Java
- smarty半小时快速上手教程
- java编码之BASE64
- spark 中的RDD编程 -以下基于Java api
- PickerView可以滑动选择的pickerView工具类(转载)
- CoreOS为Kubernetes量身打造分布式存储方案Torus
- (Java)LeetCode-26. Remove Duplicates from Sorted Array