- public static void main(String[] args) throws IOException {
- File file = new File("d:\\aa.txt");//要保存到的文件名路径;
- //创建输入流,读取键盘录入;
- BufferedReader in =
- new BufferedReader(new InputStreamReader(System.in));
- //创建输出流,保存到文件中;
- BufferedWriter out =
- new BufferedWriter(new FileWriter(file));
- String len = null;
- while((len=in.readLine())!=null){
- out.write(len);
- out.newLine();
- out.flush();
- if(len.equals("over"))
- break;
- }
- in.close();
- out.close();
- }
- }
复制代码 |