Sunday, May 3, 2015

Code Snippets

Open a File

try (FileInputStream fis = new FileInputStream(file)) {

 try (BufferedReader reader = new BufferedReader(new InputStreamReader(fis))) {

  String line = reader.readLine();
  System.err.println(line);

  while (line != null) {
   line = reader.readLine();
   System.err.println(line);
  }
 }
}

No comments:

Post a Comment