本帖最后由 yjf997234900 于 2011-12-20 09:50 编辑
- import java.io.*;
- class PrintWriterDemo
- {
- public static void main(String[] args) throws IOException
- {
- BufferedReader bufr=new BufferedReader(new InputStreamReader(System.in));
- PrintWriter out1=new PrintWriter(new FileWriter("a.txt"),true );
- String line=null;
- while((line=bufr.readLine())!=null)
- {
- if("over".equals(line))
- {
- break;
- }
- out1.println(line.toUpperCase());
- }
- out1.close();
- bufr.close();
- }
- }
复制代码 复制代码我在控制台输入:
jas
wq
sa
d
zx
over
运行结果是:
JAS
JAS
JAS
JAS
JAS
JAS
而且输入over不能结束输入
|
|