Skip to content

Instantly share code, notes, and snippets.

@imanabu
Last active August 9, 2019 22:19
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 imanabu/6630b2b302aeaf4d457ffbad19a05049 to your computer and use it in GitHub Desktop.
Save imanabu/6630b2b302aeaf4d457ffbad19a05049 to your computer and use it in GitHub Desktop.
Read a Java8 Reousrce File and then Parse into String in 3 lines
ClassLoader classLoader = getClass().getClassLoader();
String fn = classLoader.getResource("some-file.txt").getFile();
String txt = new String(Files.readAllBytes(Paths.get(fn.substring(1)))); // Skips the first / of /c:/ in Windows
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment