Read text from standard input

From CodeCodex

Revision as of 00:24, 16 December 2006 by 71.197.105.227 (Talk)

Implementations

Common Lisp

(funcall #'(lambda () (format t "> prompt ") (read-line)))
> prompt fooey
"fooey" ;
NIL

Java

    try {
        BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
        String str = "";
        while (str != null) {
            System.out.print("> prompt ");
            str = in.readLine();
            process(str);
        }
    } catch (IOException e) {
    }

OCaml

# Printf.printf "> prompt %!";
  input_line stdin;;
> prompt fooey
- : string = "fooey"