try{ A = Integer.parseInt(reader.readLine()); B = Integer.parseInt(reader.readLine()); } catch(IOException e){ e.getStackTrace(); } finally{ try{ /*why try catch in final block as well?*/ reader.close(); } catch(IOException e){ e.printStackTrace(); } }