Java Scanner(Path source, String charsetName) Constructor
Syntax
Scanner(Path source, String charsetName) constructor from Scanner has the following syntax.
public Scanner(Path source, String charsetName) throws IOException
Example
In the following code shows how to use Scanner.Scanner(Path source, String charsetName) constructor.
// w ww.j ava2 s .c om
import java.nio.charset.StandardCharsets;
import java.nio.file.FileSystems;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
Scanner scanner = new Scanner(FileSystems.getDefault().getPath("logs", "access.log"),StandardCharsets.UTF_8.name());
System.out.println(scanner.nextLine());
scanner.close();
}
}
Home »
Java Tutorial »
java.util »
Java Tutorial »
java.util »