Scanner(InputStream source) constructor from Scanner has the following syntax.
public Scanner(InputStream source)
In the following code shows how to use Scanner.Scanner(InputStream source) constructor.
import java.io.FileInputStream; import java.util.Scanner; /* w w w. ja va2 s . co m*/ public class Main { public static void main(String[] args) throws Exception { Scanner scanner = new Scanner(new FileInputStream("c:/text.txt")); System.out.println(scanner.nextLine()); scanner.close(); } }