| 101 | |
| 102 | // ================================================================== |
| 103 | private static String getLine(String p, boolean b) { |
| 104 | String response; |
| 105 | |
| 106 | if (c != null) { |
| 107 | // Standard console mode |
| 108 | if (b) { |
| 109 | response = new String(c.readPassword(p)); |
| 110 | } else |
| 111 | response = c.readLine(p); |
| 112 | |
| 113 | } else { |
| 114 | // For instance when testing from Eclipse |
| 115 | BufferedReader in = new BufferedReader(new InputStreamReader(System.in)); |
| 116 | |
| 117 | System.out.print(p); |
| 118 | |
| 119 | try { |
| 120 | // Cannot suppress echo for password entry |
| 121 | response = in.readLine(); |
| 122 | } catch (IOException e) { |
| 123 | response = ""; |
| 124 | } // end of try/catch |
| 125 | |
| 126 | } // endif c |
| 127 | |
| 128 | return (response.isEmpty()) ? null : response; |
| 129 | } // end of getLine |
| 130 | |
| 131 | } |