Datasets:
ArXiv:
License:
Stack-Repo / data /train /akash-coded /FSD_Java /Lesson-3 /Exception Handling /Examples /ThrowsExample1.java
Download data/train/akash-coded/FSD_Java/Lesson-3/Exception Handling/Examples/ThrowsExample1.java from RepoFusion/Stack-Repo: direct link, hf CLI and curl.
- Browser
- Download file 656 Bytes
-
https://huggingface.co/datasets/RepoFusion/Stack-Repo/resolve/bbc90aef76314892f2d54f85da32b81503fb7eb3/data/train/akash-coded/FSD_Java/Lesson-3/Exception%20Handling/Examples/ThrowsExample1.java
- Command line
-
hf download 'hf://datasets/RepoFusion/Stack-Repo@bbc90aef76314892f2d54f85da32b81503fb7eb3/data/train/akash-coded/FSD_Java/Lesson-3/Exception Handling/Examples/ThrowsExample1.java'
-
curl -L -o ThrowsExample1.java https://huggingface.co/datasets/RepoFusion/Stack-Repo/resolve/bbc90aef76314892f2d54f85da32b81503fb7eb3/data/train/akash-coded/FSD_Java/Lesson-3/Exception%20Handling/Examples/ThrowsExample1.java
656 Bytes
| import java.io.*; | |
| class M { | |
| void method() throws IOException { | |
| throw new IOException("device error"); | |
| // try { | |
| // throw new IOException("device error"); | |
| // } catch (IOException ex) { | |
| // System.out.println("Caught inside M class" + ex); | |
| // } | |
| } | |
| } | |
| /** | |
| * Case1: You handle the exception | |
| */ | |
| public class ThrowsExample1 { | |
| public static void main(String args[]) { | |
| try { | |
| M m = new M(); | |
| m.method(); | |
| } catch (Exception e) { | |
| System.out.println("exception handled inisde main method"); | |
| } | |
| System.out.println("normal flow..."); | |
| } | |
| } | |