java 文件读取
来源:互联网 发布:2016网络神曲排行榜 编辑:程序博客网 时间:2024/04/25 14:28
File copy
public void fileCopy(String file,String target){ try(InputStream inputStream = new FileInputStream(file)){ try(OutputStream outputStream = new FileOutputStream (target)){ byte [] buffer = new byte[4096]; int bytesToRead; while((bytesToRead=inputStream.read(buffer))!=-1){ outputStream.write(buffer,0,bytesToRead); } } } catch (IOException e) { e.printStackTrace(); } } public void copyNio(String file,String target){ try(FileInputStream inputStream = new FileInputStream(file)){ try(FileOutputStream outputStream = new FileOutputStream(target)){ FileChannel inChannel = inputStream.getChannel(); FileChannel oUTChannel = outputStream.getChannel(); java.nio.ByteBuffer buffer = java.nio.ByteBuffer.allocate(4096); while(inChannel.read(buffer)!=-1){ buffer.flip(); oUTChannel.write(buffer); buffer.clear(); } } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } }
0 0
- java读取ini文件
- JAVA读取XML文件
- java读取中文文件
- Java读取文件
- JAVA读取XML文件
- java读取中文文件
- java读取pdf文件
- JAVA读取word文件
- JAVA读取PDF文件
- java读取word文件
- java读取excel文件
- java读取excel 文件
- java 读取文件(中文)
- java读取文件源代码
- java 读取文件
- Java读取Properties文件
- java读取.properties文件
- Java读取文件
- 设计模式——Java动态代理
- C语言最简开发环境(续一)
- Scrolview 嵌套ListView 导致ListView条目不能展开的问题及原理详解
- 屏幕色温
- 【Coursera】编程题 Collinear Points
- java 文件读取
- 技术积累
- Redis使用详解之redhat系统上安装redis-3.2.8
- HDU 3047 Zjnu Stadium(带权并查集)
- leetcode解题之121 # Best Time to Buy and Sell Stock
- Matlab中几种括号的区别
- Simplify Path
- android四种启动lanuchMode
- 动画效果