Exemplo n.º 1
1
    public void run() {
      try {
        // An arbitrary buffer size.
        char[] chbuf = new char[4096];

        while (keepRunning) {
          int numchars = reader.read(chbuf);
          if (numchars == -1) {
            keepRunning = false;
          } else if (keepRunning) {
            writer.write(chbuf, 0, numchars);
            if (!reader.ready()) {
              writer.flush();
            }
          }
        }
      } catch (IOException ex) {
        println("Error when linking JVM output to terminal window input.");
      }
    }