- import java.io.*;
- import java.util.*;
- class Demo
- {
- public static void main(String[] args) throws Exception
- {
- Scanner keyIn=new Scanner(System.in);
- PrintWriter outText=new PrintWriter(new FileOutputStream("a.txt"),true);
- String line=null;
- System.out.println("请输入要录入的内容。输入overin或者按Ctrl+C结束录入");
-
- while (keyIn.hasNextLine())
- {
- line=keyIn.nextLine();
- if("overin".equals(line))
- break;
- outText.println(line);
- }
- keyIn.close();
- outText.close();
- }
- }
复制代码 |