in modules/jdktools/src/main/java/org/apache/harmony/tools/keytool/ArgumentsParser.java [852:883]
static boolean getConfirmation(String promt, boolean acceptAnother)
throws IOException, KeytoolException {
int counter = 0;
while (counter++ < 100) {
System.out.print(promt);
charsRead = in.read(readData);
// if pressed ENTER return the default value
if (charsRead == newLineLength) {
return false;
}
// confirm, if the user enters 'y' or "yes"
if ((charsRead == newLineLength + 1 && (readData[0] == 'y' || readData[0] == 'Y'))
|| (charsRead == newLineLength + 3 && "yes"
.equalsIgnoreCase(new String(readData).substring(0,
3)))) {
return true;
} else if (acceptAnother) {
return false;
} else {
// if entered 'n' or "no"
if (readData[0] == 'n'
|| readData[0] == 'N'
&& ((charsRead == newLineLength + 1) || (charsRead == newLineLength + 2
&& readData[0] == 'o' || readData[0] == 'O'))) {
return false;
} else {
System.out.println("Wrong answer, please, try again");
}
}
}
throw new KeytoolException("Too many failures. ");
}