wiley_pastebin

closingstreams 3

Mar 15th, 2019
2,560
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.49 KB | None | 0 0
  1. public void processFile(String filename){
  2.  try {
  3.   String line;
  4.   BufferedReader br = null;
  5.   try {
  6.    br = new BufferedReader(new FileReader(filename));
  7.    line = br.readLine();
  8.   } catch (FileNotFoundException e) {
  9.    // deal with file not found exception
  10.   } catch (IOException e) {
  11.    // deal with other io exceptions
  12.   } finally {
  13.    if(br != null) {
  14.    br.close();
  15.   }
  16.  }
  17. } catch (IOException e){
  18.   // if close throws an exception – very unlikely
  19.  }
  20. }
Add Comment
Please, Sign In to add comment