复制图片和MP3

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException; public class inputstream { /**
* @param args
*/
public static void main(String[] args) {
// TODO Auto-generated method stub
//test1();//复制图片
test2();//复制MP3
}
static void test1(){
FileInputStream fis = null;
FileOutputStream fos = null;
try {
fis = new FileInputStream("F:\\0.jpg");
fos = new FileOutputStream("F:\\fd.jpg");
byte[] byte1 = new byte[1024];
int x = 0;
while((x = fis.read(byte1))!=-1){
fos.write(byte1, 0, x);
} } catch (IOException e) {
// TODO: handle exception
}
finally{
try {
if(fis != null)
fis.close();
} catch (IOException e2) {
// TODO: handle exception
}
try {
if(fos!=null)
fos.close();
} catch (IOException e2) {
// TODO: handle exception
}
}
}
static void test2(){
BufferedInputStream bufi = null;
BufferedOutputStream bufo = null;
try {
bufi = new BufferedInputStream(new FileInputStream("F:\\fd.mp3"));
bufo = new BufferedOutputStream(new FileOutputStream("F:\\wzz.mp3"));
byte[] b = new byte[1024];
int x = 0;
while((x=bufi.read(b))!=-1){
bufo.write(b, 0, x);
}
} catch (IOException e) {
// TODO: handle exception
}
finally{
try {
if(bufi!=null)
bufi.close();
} catch (IOException e2) {
// TODO: handle exception
}
try {
if(bufo!=null)
bufo.close();
} catch (IOException e2) {
// TODO: handle exception
}
}
}
}

最新文章

  1. CentOS 6安装PostgreSQL
  2. [Linux] LVM的条带化
  3. Hive tuning tips
  4. [转] java书籍(给Java程序猿们推荐一些值得一看的好书 + 7本免费的Java电子书和教程 )
  5. SQL 分组排序分页(大神帮写的膜拜一下)
  6. NGINX(三)HASH表
  7. asp:时间的计算
  8. Redis介绍
  9. CSS and JavaScript Bundling and Minification in ASP.NET 4.5
  10. (转) c++ 迭代器
  11. errorPlacement的位置问题
  12. 页面设计-数据列表 DataGrid
  13. (扩展根目录容量方法汇总)把Linux系统迁移到另一个分区或者硬盘
  14. java中解析excel 批量插入数据库
  15. Girls and Boys HDU - 1068 二分图匹配(匈牙利)+最大独立集证明
  16. jenkins默认会存放目录
  17. 如何打jar包
  18. LeetCode - Top K Frequent Words
  19. 关联与下钻:快速定位MySQL性能瓶颈的制胜手段
  20. rpm 安装zabbix 注意

热门文章

  1. Oracle(一)
  2. EF--DBFirst
  3. [ SHOI 2012 ] 随机树
  4. [ SDOI 2011 ] 打地鼠
  5. 表格对象的获取和更改(原生js)
  6. [转]python模块全面
  7. html5——动画案例(时钟)
  8. 仿iphone动态萤火虫锁屏应用安卓源码
  9. Python语言之变量2(命名规则,类型转换)
  10. Linux监控实时log