日期:2014-05-20 浏览次数:20815 次
package iotest;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
public class CopyChineseFile {
public static void main(String[] args) {
String encodeName = System.getProperty("file.encoding");
System.out.println("当前你的OS编码是" + encodeName);
String inputFilename = "d:\\input.txt";
String outputFilename = "d:\\output.txt";
BufferedReader bin = null;
BufferedWriter bout = null;
try {
bin = new BufferedReader(new InputStreamReader(new FileInputStream(
inputFilename), encodeName));
bout = new BufferedWriter(new OutputStreamWriter(
new FileOutputStream(outputFilename), encodeName));
int c = -1;
while ((c = bin.read()) != -1) {
bout.write(c);
}
bin.close();
bout.close();
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}