文件複製又分爲兩種情況:
1、純文本文件複製,可以使用字符流,也可以使用字節流
讀取文件內容:
1.1、使用字符流
FileReader fr = new FileReader("a.txt");
1.2、使用字節流
FileInoputStream fis = new FileInputStream("a.txt");
複製寫文件內容:
字符流:FileWriter fw = new FileWriter("a_copy.txt");
字節流:FileOutoutStream fis = new FileInoutStream("a_copy.txt");
2、媒體文件複製,只能用字節流對象
讀取文件: FileInputStream fis = new FileInputStream("a.txt");
寫文件: FileOutoutStream fis = new FileInoutStream("a_copy.txt");