Skip to content

Instantly share code, notes, and snippets.

@juananpe
Created March 8, 2023 10:24
Show Gist options
  • Save juananpe/5dd83b7a69c5a73b98c17c699615412d to your computer and use it in GitHub Desktop.
Save juananpe/5dd83b7a69c5a73b98c17c699615412d to your computer and use it in GitHub Desktop.
read text file from resources folder
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