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