Skip to content

Instantly share code, notes, and snippets.

@jeremyheiler
Last active January 3, 2016 07:39
Show Gist options
  • Save jeremyheiler/8431254 to your computer and use it in GitHub Desktop.
Save jeremyheiler/8431254 to your computer and use it in GitHub Desktop.
Read a file with one line of Java.
import java.net.URI;
import java.nio.file.Files;
import java.nio.file.Paths;
public class Main {
public static void main(String[] args) throws Exception {
System.out.println(new String(Files.readAllBytes(Paths.get("/foo.txt")), "UTF-8"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment