第一次用finally,产生了意想不到的后果,代码贴出
try {
System.out.println("The dest file \"" + dest
+ "\" is exist. Would you overwrite it?");
System.out.println("Y[Yes]/N[No]/B[Backup]?");
BufferedReader br = new BufferedReader(new InputStreamReader(
System.in));
String str = null;
str = br.readLine();
str = str.trim();
switch (str.charAt(0)) {
case 'Y':
case 'y':return ASK_YES;
case 'N':
case 'n':return ASK_NO;
case 'B':
case 'b':return ASK_BAK;
default : return ASK_NONE;
}
} catch (IOException ie) {
ie.printStackTrace();
} finally {
return ASK_NONE;
}
这段代码永远返回ASK_NONE……