public class Hello
{
public static void main(String [] args)
{
Hello hello = new Hello();
hello.doRead();
/*DataInputStream d = new DataInputStream(new BufferedInputStream(System.in));
int s;
try{
s = d.readInt();
System.out.println(s);
int b = d.readInt();
System.out.println(b);
int sum = s + b;
System.out.println(sum);
}catch(IOException e)
{
e.printStackTrace();
}*/
}
public void doRead(){
System.out.println("请输入第一个整型数字,回车");
int numA,numB;
BufferedReader brKey = new BufferedReader(new InputStreamReader(System.in));
try {
numA = Integer.parseInt(brKey.readLine());
System.out.println("请再输入一个整型数字,回车");
numB = Integer.parseInt(brKey.readLine());
System.out.println("两数之和:"+(numA+numB));
brKey.close();
} catch (IOException e) {
// TODO Auto-generated catch block
System.out.println("读取错误,程序已经退出运行");
System.exit(0);
}catch(NumberFormatException e){
System.out.println("请输入整型数字,程序已经退出运行");
System.exit(0);
}
}
}