JAVA io流筆記04 字元流
package FileText;
import java.io.File;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.Reader;
import java.io.Writer;
public class FileReader04 {
public static void main(String args[]){
File file = new File("D:/text/dd/text.txt");
File file2 = new File("D:/text/dd/newtext.txt");
try {
Reader read = new FileReader(file); //方法
char[] cha = new char[1024];
int len=0;
if(-1!=(len=read.read(cha))){
System.out.println(cha);
Writer write = new FileWriter(file2);
write.write(cha, 0, len);
write.flush();
write.close();
read.close();
}
} catch (IOException e) {
e.printStackTrace();
}
}
}