code: public void repl(String prompt, String end) {
          BufferedReader input;
          String line;
          Object[] result;
  
          input = new BufferedReader(new InputStreamReader(System.in));
          while (true) {
              System.out.print(prompt);
              try {
                  line = input.readLine();
              } catch (IOException e) {
                  System.out.println("io error: " + e.toString());
                  return;
              }
              if (line == null) {
                  // EOF (ctrl-d on unix, ctrl-c on windows)
                  return;
              }
              if (line.equals(end)) {
                  return;
              }
              try {
                  result = run("", new StringReader(line));
              } catch (IOException e) {
                  throw new IllegalStateException("unexpected io exception from StringReader", e);
              }
              if ((result != null) && (result.length > 0)) {
                  System.out.println(result[0]);
              }
          }
      }
docs: Read-eval-print loop. Loop terminates if the specified end string is
  entered. This method is handy to test mappers interactively.
  TODO: should print all attributes returned by the mapper,
  but currently, this would also print transport attributes.
  
  @param prompt  prompt string.
  @param end     string to terminal real-eval-print loop; null specifies
  that the loop will not be terminated.