| 124 | |
| 125 | // ================================================================== |
| 126 | private static String getLine(String p, boolean b) { |
| 127 | String response; |
| 128 | |
| 129 | if (c != null) { |
| 130 | // Standard console mode |
| 131 | if (b) { |
| 132 | response = new String(c.readPassword(p)); |
| 133 | } else |
| 134 | response = c.readLine(p); |
| 135 | |
| 136 | } else { |
| 137 | // For instance when testing from Eclipse |
| 138 | BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); |
| 139 | |
| 140 | System.out.print(p); |
| 141 | |
| 142 | try { |
| 143 | // Cannot suppress echo for password entry |
| 144 | response = in.readLine(); |
| 145 | } catch (IOException e) { |
| 146 | response = ""; |
| 147 | } // end of try/catch |
| 148 | |
| 149 | } // endif c |
| 150 | |
| 151 | return (response.isEmpty()) ? null : response; |
| 152 | } // end of getLine |
| 153 | |
| 154 | } // end of class Client |