Created
March 8, 2023 10:24
-
-
Save juananpe/5dd83b7a69c5a73b98c17c699615412d to your computer and use it in GitHub Desktop.
read text file from resources folder
This file contains 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
public String readFile(String filename) { | |
String content = ""; | |
try { | |
// read filename from resources folder | |
URL fileURL = getClass().getResource(filename); | |
content = new String ( Files.readAllBytes( Paths.get( fileURL.getFile() ) ) ); | |
} | |
catch (IOException e) { | |
e.printStackTrace(); | |
} | |
return content; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment