首页 > 代码库 > Java_io_PrintWriter和BufferedReader
Java_io_PrintWriter和BufferedReader
package stream;
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
public class TestReader {
public static void main(String[] args) {
BufferedReader br=null;
PrintWriter out=null;
try {
br=new BufferedReader(new FileReader("D:\\JAVA SE\\temp\\main.txt"));
out =new PrintWriter(new BufferedWriter(new FileWriter("D:\\JAVA SE\\temp\\main的new.txt")),true);
String str=null;
while((str=br.readLine())!=null){
out.println(str);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
if(br!=null)
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
if(out!=null) out.close();
}
}
}
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;
import java.io.PrintWriter;
public class TestReader {
public static void main(String[] args) {
BufferedReader br=null;
PrintWriter out=null;
try {
br=new BufferedReader(new FileReader("D:\\JAVA SE\\temp\\main.txt"));
out =new PrintWriter(new BufferedWriter(new FileWriter("D:\\JAVA SE\\temp\\main的new.txt")),true);
String str=null;
while((str=br.readLine())!=null){
out.println(str);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}finally{
if(br!=null)
try {
br.close();
} catch (IOException e) {
e.printStackTrace();
}
if(out!=null) out.close();
}
}
}
Java_io_PrintWriter和BufferedReader
声明:以上内容来自用户投稿及互联网公开渠道收集整理发布,本网站不拥有所有权,未作人工编辑处理,也不承担相关法律责任,若内容有误或涉及侵权可进行投诉: 投诉/举报 工作人员会在5个工作日内联系你,一经查实,本站将立刻删除涉嫌侵权内容。