文本文件的复制
package com.yuzhenc.io;
import java.io.*;
public class Test09 {
public static void main(String[] args) throws IOException {
File file = new File("d:\\tmp\\testcopy.sql");
File file1 = new File("d:\\tmp\\test.sql");
FileInputStream fileInputStream = new FileInputStream(file1);
InputStreamReader inputStreamReader = new InputStreamReader(fileInputStream,"utf-8");
FileOutputStream fileOutputStream = new FileOutputStream(file);
OutputStreamWriter outputStreamWriter = new OutputStreamWriter(fileOutputStream,"gbk");
char[] chars = new char[10];
int len;
while((len = inputStreamReader.read(chars)) != -1) {
outputStreamWriter.write(chars,0,len);
}
outputStreamWriter.close();
inputStreamReader.close();
fileOutputStream.close();
fileInputStream.close();
}
}