Skip to content

Instantly share code, notes, and snippets.

@arn-e
Last active December 11, 2015 03:59
Show Gist options
  • Save arn-e/4541940 to your computer and use it in GitHub Desktop.
Save arn-e/4541940 to your computer and use it in GitHub Desktop.
handled checked exception in Java
public class FileReaderTest {
public static void main(String[] args) {
String filename = "./public/index.html";
try {
List<String> allLines = Files.readAllLines(Paths.get(filename), Charset.defaultCharset());
for ( String i : allLines ) {
System.out.println(i);
}
} catch(IOException exception) {
exception.printStackTrace();
throw new RuntimeException("Oh, a Runtime Exception?");
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment