Java examples for File Path IO:File Operation
To read the entire contents of a file at once
import java.io.IOException; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class Main { public static void main(String[] args) throws IOException { Path path = Paths.get("/home/docs/users.txt"); byte[] contents = Files.readAllBytes(path); for (byte b : contents) { System.out.print((char) b); }/*from w w w .j a va 2 s.com*/ } }