1 import java.io.FileInputStream; 2 import java.io.FileNotFoundException; 3 import java.io.FileOutputStream; 4 import java.io.IOException; 5 6 public class CopyFileDemo { 7 public static void main(String[] args) { 8 9 FileInputStream fis = null; 10 FileOutputStream fos = null; 11 try { 12 fis = new FileInputStream(\"js.mp3\"); 13 fos = new FileOutputStream(\"copy_js.mp3\"); 14 // BufferedInputStream bis=new BufferedInputStream(fis); 15 // BufferedOutputStream bos=new BufferedOutputStream(fos); 16 byte[] bt = new byte[1024]; 17 int len = 0; 18 while ((len = fis.read(bt)) != -1) { 19 fos.write(bt, 0, len); 20 } 21 } catch (FileNotFoundException e) { 22 e.printStackTrace(); 23 } catch (IOException e) { 24 e.printStackTrace(); 25 } finally { 26 try { 27 if (fis != null) 28 fis.close(); 29 if (fos != null) 30 fos.close(); 31 } catch (IOException e) { 32 e.printStackTrace(); 33 } 34 } 35 } 36 }
继续阅读与本文标签相同的文章
上一篇 :
Web安全常见漏洞修复建议
下一篇 :
真正的区块链操作系统有可能实现吗?
-
《21天学通JavaScript(第5版)》| 每日读本书
2026-05-19栏目: 教程
-
Unity火爆插件Behavior Designer行为树插件学习
2026-05-19栏目: 教程
-
结合 Mybatis,探讨 Oracle 中 in 与 not in 的陷阱
2026-05-19栏目: 教程
-
阿里云文件网关备份
2026-05-19栏目: 教程
-
UITableView 组件化
2026-05-19栏目: 教程
