Created
July 1, 2015 09:12
-
-
Save friek/4ecc591f1fea6cbf2586 to your computer and use it in GitHub Desktop.
One liner for reading a file in Java.
This file contains hidden or 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
| package file; | |
| import java.io.IOException; | |
| import java.nio.charset.Charset; | |
| import java.nio.file.Files; | |
| import java.nio.file.Paths; | |
| public class FileReader | |
| { | |
| public static void main(String[] args) throws IOException | |
| { | |
| System.out.print(new String(Files.readAllBytes(Paths.get("/etc/passwd")), Charset.forName("UTF-8"))); | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment