lamiastella

try with resources

Mar 28th, 2016
277
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.40 KB | None | 0 0
  1. try (FileInputStream fis = new FileInputStream(newFile)) {
  2.             System.out.println("fis");
  3.             System.out.println(fis.read()); //prints 77
  4.             int content;
  5.             while ((content = fis.read()) != -1) {
  6.                 System.out.print((char) content);
  7.             }
  8.             fis.close();
  9.         }
  10.         catch (IOException e){
  11.             e.printStackTrace();
  12.         }
Advertisement
Add Comment
Please, Sign In to add comment