package exp9; import java.io.*; public class ExceptionExmaple2 { public static void main(String args[]) throws NumberFormatException { System.out.println("Please Input an Interger:"); try{ //此处可能会抛出I/O异常 BufferedReader in=new BufferedReader(new InputStreamReader(System.in)); int a=Integer.parseInt(in.readLine()); //此处可能会抛出数据格式异常 System.out.println("the Integer you input is:"+a); } catch(IOException e) //捕获I/O异常并处理 { System.out.println("I/O error"); } } }