Files.newInputStream(Path path, OpenOption ... options) has the following syntax.
public static InputStream newInputStream(Path path, OpenOption ... options) throws IOException
In the following code shows how to use Files.newInputStream(Path path, OpenOption ... options) method.
//from www. j ava2 s.c om import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; 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 rn_demo = Paths.get("C:/tutorial/Java", "demo.txt"); //using NIO.2 unbuffered stream int n; try (InputStream in = Files.newInputStream(rn_demo)) { while ((n = in.read()) != -1) { System.out.print((char) n); } } catch (IOException e) { System.err.println(e); } } }