package com_01;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
public class IODemo3 {
public static void main(String[] args) {
FileWriter fw = null;
FileReader fr = null;
try {
fw = new FileWriter("D:\\a.txt");
fr = new FileReader("D:\\安装包\\PotPlayer_V1.6.52514.0_Setup.1422959344.exe");
// int ch = fr.read();
char[] chs = new char[100];
int len = 0;
while ((len = fr.read(chs)) != -1) {
fw.write(chs);
System.out.print(new String(chs, 0, len));
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
} finally {
if (fr != null) {
try {
fw.close();
fr.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}
}
|