dragonslayer0531

Resource Loader

Dec 12th, 2016
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.32 KB | None | 0 0
  1. public static String loadResource(String fileName) throws Exception {
  2.     String result = "";
  3.     try (InputStream in = Resources.class.getClass().getResourceAsStream(fileName)) {
  4.         Scanner scanner = new Scanner(in, "UTF-8");
  5.         scanner.useDelimiter("\\A");
  6.         result = scanner.next();
  7.         scanner.close();
  8.     }
  9.     return result;
  10. }
Advertisement
Add Comment
Please, Sign In to add comment