1 package a.ab;
 2 
 3 import java.io.FileInputStream;
 4 import java.io.FileNotFoundException;
 5 import java.io.FileOutputStream;
 6 import java.io.IOException;
 7 
 8 public class ClassA {
 9     public static void main(String[] args) {
10         try {
11             FileInputStream fis = new FileInputStream(
12                     "C:\\Program Files\\feiq\\Recv Files\\001.jpg");
13             FileOutputStream fos = new FileOutputStream(
14                     "C:\\Program Files\\feiq\\Recv Files\\003.jpg");
15             int len = 0;
16             byte[] bytes = new byte[1024];
17             try {
18                 while ((len = fis.read(bytes)) != -1) {
19                     fos.write(bytes, 0, len);
20                 }
21             } catch (IOException e) {
22                 e.printStackTrace();
23             } finally {
24                 if (fis != null) {
25                     try {
26                         fis.close();
27                     } catch (IOException e) {
28                         e.printStackTrace();
29                     }
30                 }
31                 if (fos != null) {
32                     try {
33                         fos.close();
34                     } catch (IOException e) {
35                         e.printStackTrace();
36                     }
37                 }
38             }
39         } catch (FileNotFoundException e) {
40             e.printStackTrace();
41         }
42 
43     }
44 }
View Code

相关文章:

  • 2020-04-09
  • 2021-12-10
  • 2021-10-05
  • 2021-08-27
  • 2021-05-18
  • 2022-12-23
  • 2022-03-05
  • 2021-04-29
猜你喜欢
  • 2021-06-20
  • 2021-08-02
  • 2022-12-23
  • 2022-12-23
  • 2021-10-30
  • 2021-10-24
  • 2021-09-08
相关资源
相似解决方案