1 23 24 package com.sun.enterprise.cli.framework; 25 26 import java.io.BufferedReader ; 27 import java.io.BufferedWriter ; 28 import java.io.IOException ; 29 import java.io.Reader ; 30 import java.io.Writer ; 31 32 class User 33 { 34 private BufferedReader fromUser; 35 private BufferedWriter toUser; 36 private String quit; 37 private String prompt; 38 39 User(Reader in, Writer out, String quitPrefix, String prompt){ 40 fromUser = new BufferedReader (in); 41 toUser = new BufferedWriter (out); 42 quit = quitPrefix; 43 this.prompt = prompt; 44 } 45 50 boolean wantsToContinue() throws IOException { 51 toUser.write(prompt); 52 toUser.newLine(); 53 toUser.flush(); 54 return !fromUser.readLine().startsWith(quit); 55 } 56 57 void handleException (Exception e) throws IOException { 58 toUser.write(e.getMessage()); 59 toUser.flush(); 60 } 61 62 } 63 | Popular Tags |