src/share/classes/java/util/Scanner.java

Print this page

        

@@ -23,11 +23,12 @@
  * questions.
  */
 
 package java.util;
 
-import java.nio.file.FileRef;
+import java.nio.file.Path;
+import java.nio.file.Files;
 import java.util.regex.*;
 import java.io.*;
 import java.math.*;
 import java.nio.*;
 import java.nio.channels.*;

@@ -697,44 +698,44 @@
      * from the specified file. Bytes from the file are converted into
      * characters using the underlying platform's
      * {@linkplain java.nio.charset.Charset#defaultCharset() default charset}.
      *
      * @param   source
-     *          A file to be scanned
+     *          the path to the file to be scanned
      * @throws  IOException
      *          if an I/O error occurs opening source
      *
      * @since   1.7
      */
-    public Scanner(FileRef source)
+    public Scanner(Path source)
         throws IOException
     {
-        this(source.newInputStream());
+        this(Files.newInputStream(source));
     }
 
     /**
      * Constructs a new <code>Scanner</code> that produces values scanned
      * from the specified file. Bytes from the file are converted into
      * characters using the specified charset.
      *
      * @param   source
-     *          A file to be scanned
+     *          the path to the file to be scanned
      * @param   charsetName
      *          The encoding type used to convert bytes from the file
      *          into characters to be scanned
      * @throws  IOException
      *          if an I/O error occurs opening source
      * @throws  IllegalArgumentException
      *          if the specified encoding is not found
      * @since   1.7
      */
-    public Scanner(FileRef source, String charsetName) throws IOException {
+    public Scanner(Path source, String charsetName) throws IOException {
         this(Objects.nonNull(source), toCharset(charsetName));
     }
 
-    private Scanner(FileRef source, Charset charset)  throws IOException {
-        this(makeReadable(source.newInputStream(), charset));
+    private Scanner(Path source, Charset charset)  throws IOException {
+        this(makeReadable(Files.newInputStream(source), charset));
     }
 
     /**
      * Constructs a new <code>Scanner</code> that produces values scanned
      * from the specified string.