- /*
- 读取键盘录入;
- 要求:当录入一行数据后,就将该数据打印。
- 如果录入数据是over,那么停止录入。
- */
- import java.io.*;
- class readIn
- {
- public static void main(String[] args) throws IOException
- {
- InputStream is = System.in;
- StringBuilder sb = new StringBuilder();
- while (true)
- {
- int by =is.read();
- if (by=='\r')
- {
- continue ;
- }
- if (by=='\n')
- {
- String s = sb.toString();
- if ("over".equals(s))
- {
- break;
- }
- System.out.println(s.toUpperCase());
- sb.delete(0,sb.length());
-
- }
-
- else
- sb.append((char)by);
-
- }
-
-
- }
- }
复制代码
|
|