【Java开源代码栏目提醒】:网学会员鉴于大家对Java开源代码十分关注,论文会员在此为大家搜集整理了“TryCatchException.java”一文,供大家参考学习
import java.io.*;
public class TryCatchException {
public static void main(String[] args) throws IOException {
BufferedReader buf;
String str;
while (true) {
buf = new BufferedReader(new InputStreamReader(System.in));
System.out.print("请输入数字:");
str = buf.readLine();
try {
Integer.valueOf(str);
System.out.println("转型成功!!!");
} catch (NumberFormatException e) {
System.out.println("转型失败,异常输出内容:" + e);
}
}
}
}