Last active
August 9, 2019 22:19
-
-
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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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