Skip to content

Instantly share code, notes, and snippets.

@gauravssnl
Created September 6, 2021 13:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save gauravssnl/5ba6485e3edecdd61711ee08be7a0a4c to your computer and use it in GitHub Desktop.
Save gauravssnl/5ba6485e3edecdd61711ee08be7a0a4c to your computer and use it in GitHub Desktop.
ExceptionTranslation.java
// Exception translation
public
class ExceptionTranslation {
public
String readTheFile(String f) {
try
(BufferedReader is = new BufferedReader(new FileReader(f))) {
String line = is.readLine();
return line;
}
catch (FileNotFoundException fnf) {
throw new RuntimeException("Could not open file " + f, fnf);
} catch (IOException ex) {
throw new RuntimeException("Problem reading file " + f, ex);
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment