import java.io.*;class PromptAndEcho{ public static void main(String args[]) throws IOException{ if(args.length()<1){ System.err.println("java Prompt And Echo <output file>"); return;} BufferedReader stdin=new BufferedReader(new InputStreamReader(System.in)); PrintWriter pw=new PrintWriter(new FileOutputStream(args[0])); while(true){ System.out.print("input>"); String s=stdin.readLine(); if(s.equalsLgnoreCase("exit")) break; System.out.println(s); pw.println(s);} pw.close(); stdin.close(); } }

评论