日期:2014-05-20 浏览次数:20733 次
BufferedReader bfr = null; BufferedWriter bfw = null; try { bfr = new BufferedReader(new InputStreamReader(System.in)); bfw = new BufferedWriter(new FileWriter("c:/abc.txt")); int len = 0; String text = bfr.readLine(); while(!(text.equals("exit"))){ bfw.write(text); bfw.newLine(); //text = bfr.readLine(); } bfw.flush();
String text = ""; while (!(text = bfr.readLine()).equals("exit")) { bfw.write(text); bfw.newLine(); //text = bfr.readLine(); } bfw.flush();
------解决方案--------------------
1L的方法不能生成文件么?我试了可以的啊。
------解决方案--------------------
怎么可能。。。
public static void main(String args[]) throws Exception { BufferedReader bfr = null; BufferedWriter bfw = null; bfr = new BufferedReader(new InputStreamReader(System.in)); bfw = new BufferedWriter(new FileWriter("c:/abc.txt")); String text = ""; while (!(text = bfr.readLine()).equals("exit")) { bfw.write(text); bfw.newLine(); } bfw.flush(); }