public class demo03 {
public static void main(String[] args) {
//创建源仅限于字符的纯文本
File src=new File("E:/others/goodOrBad11.txt");
File dest=new File("E:/others/goodOrBad22.txt");
//选择流
Reader reader=null;
Writer writer=null;
try {
reader=new FileReader(src);
writer=new FileWriter(dest);
char[] flush=new char[1000];
int len=0;
while(-1!=(len=reader.read(flush))){
writer.write(flush, 0, len);
}
writer.flush();
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally {
try {
while (null != (reader)) {
reader.close();
}
} catch (Exception e2) {
}
try {
while (null != (writer)) {
writer.close();
}
} catch (Exception e2) {
}
}
}
}
[IO]——纯文本复制
最新推荐文章于 2017-08-06 16:04:36 发布