字符流完成文件复制
代码实现:
public static void main(String[] args) {
String str = File.separator;
FileReader fileReader = null;
FileWriter fileWriter = null;
try {
fileReader = new FileReader(“C:” + str + “ab” + str + “b.txt”);
fileWriter = new FileWriter(“C:” + str + “ab” + str + “ff.txt”);
int ch = 0;
char[] charray = new char[1024 * 1];
while ((ch = fileReader.read(charray)) != -1) {
fileWriter.write(charray, 0, ch);
}
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
} finally {
if (fileReader != null) {
try {
fileReader.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
if (fileWriter !