Datasets:
ArXiv:
License:
Stack-Repo / data /train /akash-coded /FSD_Java /Lesson-3 /Exception Handling /Examples /CheckedExceptionExample.java
Download data/train/akash-coded/FSD_Java/Lesson-3/Exception Handling/Examples/CheckedExceptionExample.java from RepoFusion/Stack-Repo: direct link, hf CLI and curl.
- Browser
- Download file 552 Bytes
-
https://huggingface.co/datasets/RepoFusion/Stack-Repo/resolve/bbc90aef76314892f2d54f85da32b81503fb7eb3/data/train/akash-coded/FSD_Java/Lesson-3/Exception%20Handling/Examples/CheckedExceptionExample.java
- Command line
-
hf download 'hf://datasets/RepoFusion/Stack-Repo@bbc90aef76314892f2d54f85da32b81503fb7eb3/data/train/akash-coded/FSD_Java/Lesson-3/Exception Handling/Examples/CheckedExceptionExample.java'
-
curl -L -o CheckedExceptionExample.java https://huggingface.co/datasets/RepoFusion/Stack-Repo/resolve/bbc90aef76314892f2d54f85da32b81503fb7eb3/data/train/akash-coded/FSD_Java/Lesson-3/Exception%20Handling/Examples/CheckedExceptionExample.java
552 Bytes
| import java.io.FileNotFoundException; | |
| import java.io.PrintWriter; | |
| public class CheckedExceptionExample { | |
| public static void main(String[] args) { | |
| PrintWriter pw = null; | |
| try { | |
| pw = new PrintWriter("jtp.txt"); // may throw exception | |
| pw.println("saved"); | |
| } | |
| // providing the checked exception handler | |
| catch (FileNotFoundException e) { | |
| System.out.println(e); | |
| } finally { | |
| pw.close(); | |
| } | |
| System.out.println("File saved successfully"); | |
| } | |
| } | |