解决方案 »

  1.   

    你只需要在System.out.write(c);后面增加一行System.out.flush();就可以了,因为write方法不会自动flush缓冲区,而是碰到回车才会flush,所以你就看不到最后一行了。附上PrintStream类的write方法源码,你看看就明白了。    public void write(int b) {
    try {
        synchronized (this) {
    ensureOpen();
    out.write(b);
    if ((b == '\n') && autoFlush)
        out.flush();
        }
    }
    catch (InterruptedIOException x) {
        Thread.currentThread().interrupt();
    }
    catch (IOException x) {
        trouble = true;
    }
        }