当前位置: 移动技术网 > IT编程>开发语言>Java > Java-IO:复制文件

Java-IO:复制文件

2018年12月11日  | 移动技术网IT编程  | 我要评论

佛山天气预报15天,车位锁厂家,黑板报设计图

 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 }

 

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网