本帖最后由 侯丛政 于 2013-2-15 19:13 编辑
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') {
if ("over".equals((char) by)) { // 我是这样定义的结束条件 但是当输入"over" 时程序不会结束 ?
break;
}
System.out.println(sb.toString());
sb.delete(0, sb.length());
} else {
sb.append((char) by);
}
}
}
|