FileInputStream fInputStream=new FileInputStream(new File("/root/Desktop/testImage.jpg"));
FileOutputStream fOutputStream =new FileOutputStream(new File("/root/Desktop/testImage2.jpg"));
FileChannel fcIn=fInputStream.getChannel();
FileChannel fcOut=fOutputStream.getChannel();
ByteBuffer buffer=ByteBuffer.allocate(1024);
//将管道的数据读入buffer中
while(fcIn.read(buffer)!=-1){
//由读操作转到写操作时必须调用flip来改变buffer的状态
//内部操作:limit=position;position=0
buffer.flip();
//把buffer的数据写入管道
fcOut.write(buffer);
//清空buffer
//内部操作:limit=capacity;position=0
buffer.clear();
}
fcIn.close();
fInputStream.close();
fcOut.close();
fOutputStream.close();

最新文章

  1. JVM内存管理------垃圾搜集器简介
  2. Samsung S4卡屏卡在开机画面的不拆机恢复照片一例
  3. Android快速开发框架LoonAndroid (转)
  4. BZOJ1004: [HNOI2008]Cards
  5. 跨站脚本 XSS<一:防御方法>
  6. poj1417 带权并查集+0/1背包
  7. Delphi 使用串口模拟工具进行串口程序开发调试
  8. MySQL相关知识
  9. JavaScript高级程序设计48.pdf
  10. Factorial Solved Problem code: FCTRL
  11. JavaScript中的execCommand()命令详解及实例展示
  12. JS放大镜特效(兼容版)
  13. 《经久不衰的Spring框架:SpringMVC 统括》
  14. HDFS Java API的使用举例
  15. JSONPath使用
  16. 数组中array==null和array.length==0的区别
  17. html问题汇总
  18. 四则运算Java语言实验设计过程1
  19. 【BZOJ】【2127】happiness
  20. c# 通过文件夹共享复制文件到服务器

热门文章

  1. ERP 能够做什么
  2. 先贴出代码C++ 中的单例模式
  3. 国内的一些开源镜像站汇总,EPEL源
  4. poj2817WordStack(状压)
  5. LA_3026_Period_(kmp)
  6. oracle rac scan ip 用途 原理
  7. SharePoint2010主题和样式揭秘
  8. 关于I/O的那点事
  9. Android学习笔记(1)—Android Studio安装
  10. hdu-5364 Distribution money