src/share/classes/java/nio/file/Files.java
Print this page
*** 23,32 ****
--- 23,33 ----
* questions.
*/
package java.nio.file;
+ import java.nio.file.DirectoryStream.Filter;
import java.nio.file.attribute.*;
import java.nio.file.spi.FileSystemProvider;
import java.nio.file.spi.FileTypeDetector;
import java.nio.channels.SeekableByteChannel;
import java.io.InputStream;
*** 395,411 ****
* method is invoked to check read access to the directory.
*/
public static DirectoryStream<Path> newDirectoryStream(Path dir)
throws IOException
{
! return provider(dir).newDirectoryStream(dir, new DirectoryStream.Filter<Path>() {
! @Override
! public boolean accept(Path entry) {
! return true;
}
- });
- }
/**
* Opens a directory, returning a {@link DirectoryStream} to iterate over
* the entries in the directory. The elements returned by the directory
* stream's {@link DirectoryStream#iterator iterator} are of type {@code
--- 396,407 ----
* method is invoked to check read access to the directory.
*/
public static DirectoryStream<Path> newDirectoryStream(Path dir)
throws IOException
{
! return provider(dir).newDirectoryStream(dir, ACCEPT_ALL);
}
/**
* Opens a directory, returning a {@link DirectoryStream} to iterate over
* the entries in the directory. The elements returned by the directory
* stream's {@link DirectoryStream#iterator iterator} are of type {@code
*** 2065,2075 ****
* readAttributes} method and the file type tested with the {@link
* BasicFileAttributes#isSymbolicLink} method.
*
* @return {@code true} if the file is a symbolic link; {@code false} if
* the file does not exist, is not a symbolic link, or it cannot
! * be determined if the file is a symbolic link or not.
*
* @throws SecurityException
* In the case of the default provider, and a security manager is
* installed, its {@link SecurityManager#checkRead(String) checkRead}
* method denies read access to the file.
--- 2061,2071 ----
* readAttributes} method and the file type tested with the {@link
* BasicFileAttributes#isSymbolicLink} method.
*
* @return {@code true} if the file is a symbolic link; {@code false} if
* the file does not exist, is not a symbolic link, or it cannot
! * be determined if the file is symbolic link or not.
*
* @throws SecurityException
* In the case of the default provider, and a security manager is
* installed, its {@link SecurityManager#checkRead(String) checkRead}
* method denies read access to the file.
*** 2104,2114 ****
* @param options
* options indicating how symbolic links are handled
*
* @return {@code true} if the file is a directory; {@code false} if
* the file does not exist, is not a directory, or it cannot
! * be determined if the file is a directory or not.
*
* @throws SecurityException
* In the case of the default provider, and a security manager is
* installed, its {@link SecurityManager#checkRead(String) checkRead}
* method denies read access to the file.
--- 2100,2110 ----
* @param options
* options indicating how symbolic links are handled
*
* @return {@code true} if the file is a directory; {@code false} if
* the file does not exist, is not a directory, or it cannot
! * be determined if the file is directory or not.
*
* @throws SecurityException
* In the case of the default provider, and a security manager is
* installed, its {@link SecurityManager#checkRead(String) checkRead}
* method denies read access to the file.
*** 3115,3120 ****
--- 3111,3125 ----
writer.newLine();
}
}
return path;
}
+
+ private final static Filter<Object> ACCEPT_ALL = new AcceptAllFilter();
+ private static class AcceptAllFilter implements Filter<Object> {
+
+ @Override
+ public boolean accept(Object entry) {
+ return true;
+ }
+ }
}