Java examples for File Path IO:File Operation
Using the newInputStream() Method to read the content of a file
import java.io.IOException; import java.io.InputStream; import java.nio.file.Files; import java.nio.file.Path; import java.nio.file.Paths; public class Main { public static void main(String[] args) { Path path = Paths.get("C:/folder1/equipment", "test.txt"); int n;// w ww .j av a2 s . com try (InputStream in = Files.newInputStream(path)) { while ((n = in.read()) != -1) { System.out.print((char) n); } } catch (IOException e) { System.err.println(e); } } }