private char[] readPasswordDefaultInput(String defaultValue, String format, Object... args) throws IOException { char[] result; if (console != null) { result = console.readPassword(format, args); if (result.length == 0) { result = defaultValue!=null?defaultValue.toCharArray():null; } } else { // Fix ConsolePasswordGroupFieldTest String line = readLine(); result = line!=null ? line.toCharArray() : null; } return result; }
/** * Displays a prompt and waits for input. * * @param prompt the prompt to display * @param defaultValue the default value to use, if no input is entered * @return the user input value; if the user input is empty (return key pressed) return defaultValue */ public String prompt(String prompt, String defaultValue) { String result; try { println(prompt); result = readLine(); if (result != null && result.isEmpty()) { result = defaultValue; } } catch (IOException e) { result = null; logger.log(Level.WARNING, e.getMessage(), e); } return result; }
String value = readLine(); if (value != null)