利用 BufferedReader实现从键盘读入字符串并写进文件abc.txt中

import java.io.*;
public class Test
{
public static void main(String[] args) throws IOException
{
BufferedReader buf = new BufferedReader (new InputStreamReader(System.in));
BufferedWriter buff = new BufferedWriter(new FileWriter("abc.txt"));
String str = buf.readLine();
while(!str.equals("exit"))
{
buff.write(str);
buff.newLine();
str = buf.readLine();
}
buf.close();
buff.close();
}
}

转载于:https://www.cnblogs.com/Java-Sun/archive/2013/05/31/3111623.html

你可能感兴趣的:(利用 BufferedReader实现从键盘读入字符串并写进文件abc.txt中)