public class Test2 {
/**
* @param args
*/
public static void main(String[] args) {
//字符流,读写文件时,以字符为基础
//字节输入流:Reader <--FileReader
//int read(char[] c,int off, int length)
//字节输出流:Writer <--FileWriter
//void write(char[] c,int off,int length)
FileReader fReader =null;
FileWriter fWriter = null;
try {
fReader = new FileReader("D:/from.txt");
fWriter = new FileWriter("d:/to.txt");
char[] buffer = new char[100];
int temp = fReader.read(buffer, 0, buffer.length);
fWriter.write(buffer, 0, temp);
}
catch(IOException e) {
e.printStackTrace();
}
finally {
try {
fReader.close();
fWriter.close();
} catch (IOException e) {
e.printStackTrace();
}
}
}
}