IO_FileReader&FileWriter
Posted changzuidaerguai
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了IO_FileReader&FileWriter相关的知识,希望对你有一定的参考价值。
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
String pathWriter = "d:" + File.separator + "javatest" + File.separator + "1.txt";
String pathReader = "d:" + File.separator + "javatest" + File.separator + "CollectionTest1.java";
FileReader fr = new FileReader(new File(pathReader));
FileWriter fw = new FileWriter(new File(pathWriter), true);
char[] bufChar = new char[1024];
int result = 0;
while((result = fr.read(bufChar)) != -1) {
fw.write(bufChar);
System.out.println(new String(bufChar, 0, result));
}
fr.close();
fw.close();
}
}
以上是关于IO_FileReader&FileWriter的主要内容,如果未能解决你的问题,请参考以下文章
Java中的IO操作 字符流:FileReader和 FileWriter