Difference between revisions of "Read text from standard input"

From CodeCodex

Line 23: Line 23:
 
[[Category:Java]]
 
[[Category:Java]]
 
[[Category:I/O]]
 
[[Category:I/O]]
 +
[[Category:Objective Caml]]

Revision as of 19:37, 31 July 2006

Implementations

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

# print_string "> prompt";
  input_line stdin;;
fooey
> prompt- : string = "fooey"