下面这个代码,如果设置over为结束语句,跳出整个循环,那么打印语句就执行不到,Eclipse中就会报错。该怎么修改呢??
- public class ReadIn {
- public static void main(String[] args) throws IOException
- {
- InputStream in = System.in;
- StringBuilder sb = new StringBuilder();
- while(true)
- {
- int ch = in.read();
- if(ch=='\r')
- continue;
- if(ch=='\n')
- {
- String s = sb.toString();
- if("over".equals(s));
- break;
- System.out.println(s);
- sb.delete(0, sb.length());
- }
- else
- sb.append((char)ch);
- }
-
- }
- }
复制代码 |
|