Skip to content

Instantly share code, notes, and snippets.

@mabako
Created November 8, 2012 09:46
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 mabako/4037837 to your computer and use it in GitHub Desktop.
Save mabako/4037837 to your computer and use it in GitHub Desktop.
java: read string into file
/**
* Read complete file into a String
*/
try(InputStream is = ...) {
try(Scanner s = new Scanner(is).useDelimiter("\\A")) {
return s.hasNext() ? s.next() : "";
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment