Skip to content

Instantly share code, notes, and snippets.

@gustavomdsantos
Last active May 11, 2016 00:20
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 gustavomdsantos/27c6e6d79a7d0e9de0d5ce129bf3330d to your computer and use it in GitHub Desktop.
Save gustavomdsantos/27c6e6d79a7d0e9de0d5ce129bf3330d to your computer and use it in GitHub Desktop.
The simplest way to read a file to String in Java, based on http://stackoverflow.com/a/3403112
private static String readFile(String filename) throws FileNotFoundException {
return new Scanner(new File(filename)).useDelimiter("\\Z").next();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment