java菜鸟写了一小段代码想通过io流复制文件 为什么没有成功请帮我看一下问题出在哪
importjava.io.*;publicclasstest{publicstaticvoidmain(String[]args){BufferedReaderbr=n...
import java.io.*;
public class test {
public static void main(String []args){
BufferedReader br =null;
BufferedWriter bw =null;
try {
br = new BufferedReader(new FileReader("e:\\test.txt"));
bw = new BufferedWriter(new FileWriter("e:\\123.txt",true));
String s = null;
while((s=br.readLine())!=null){
bw.write(s);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
} 展开
public class test {
public static void main(String []args){
BufferedReader br =null;
BufferedWriter bw =null;
try {
br = new BufferedReader(new FileReader("e:\\test.txt"));
bw = new BufferedWriter(new FileWriter("e:\\123.txt",true));
String s = null;
while((s=br.readLine())!=null){
bw.write(s);
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
} 展开
3个回答
展开全部
import java.io.*;
public class test {
public static void main(String []args){
BufferedReader br =null;
BufferedWriter bw =null;
try {
br = new BufferedReader(new FileReader("e:\\test.txt"));
bw = new BufferedWriter(new FileWriter("e:\\123.txt",true",true));
String s = null;
while((s=br.readLine())!=null){
bw.write(s+"\r\n"); //要换行
}
br.close(); //记得关闭
bw.close(); //关闭
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
public class test {
public static void main(String []args){
BufferedReader br =null;
BufferedWriter bw =null;
try {
br = new BufferedReader(new FileReader("e:\\test.txt"));
bw = new BufferedWriter(new FileWriter("e:\\123.txt",true",true));
String s = null;
while((s=br.readLine())!=null){
bw.write(s+"\r\n"); //要换行
}
br.close(); //记得关闭
bw.close(); //关闭
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
}
展开全部
输出使用 PrintWriter ,里面提供了 println方法。
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
buff流不可以用来拿到数据 BUUERE流只提供了一个缓冲区的效果而已 应该再包裹一层流 Reader and Print 利用这2个流再配合BUFFER 流就可以复制了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询