public class 键盘录入 {
public static void main(String[] args)throws IOException{
// 封装数据源
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
System.out.println("请输入数据");
BufferedWriter bw = new BufferedWriter(new FileWriter("x.txt"));
String line = null;
while((line=br.readLine())!=null){
if("over".equals(line)){
break;
}
bw.write(line);
bw.newLine();
bw.flush();
}
bw.close();
br.close();
}
} |
|