493 * stream's {@code close} method should be invoked after iteration is
494 * completed so as to free any resources held for the open directory.
495 *
496 * <p> Where the filter terminates due to an uncaught error or runtime
497 * exception then it is propagated to the {@link Iterator#hasNext()
498 * hasNext} or {@link Iterator#next() next} method. Where an {@code
499 * IOException} is thrown, it results in the {@code hasNext} or {@code
500 * next} method throwing a {@link DirectoryIteratorException} with the
501 * {@code IOException} as the cause.
502 *
503 * <p> When an implementation supports operations on entries in the
504 * directory that execute in a race-free manner then the returned directory
505 * stream is a {@link SecureDirectoryStream}.
506 *
507 * <p> <b>Usage Example:</b>
508 * Suppose we want to iterate over the files in a directory that are
509 * larger than 8K.
510 * <pre>
511 * DirectoryStream.Filter<Path> filter = new DirectoryStream.Filter<Path>() {
512 * public boolean accept(Path file) throws IOException {
513 * return (Files.size(file) > 8192L);
514 * }
515 * };
516 * Path dir = ...
517 * try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, filter)) {
518 * :
519 * }
520 * </pre>
521 *
522 * @param dir
523 * the path to the directory
524 * @param filter
525 * the directory stream filter
526 *
527 * @return a new and open {@code DirectoryStream} object
528 *
529 * @throws NotDirectoryException
530 * if the file could not otherwise be opened because it is not
531 * a directory <i>(optional specific exception)</i>
532 * @throws IOException
533 * if an I/O error occurs
1575 * attribute view defines type-safe methods to read or update the file
1576 * attributes. The {@code type} parameter is the type of the attribute view
1577 * required and the method returns an instance of that type if supported.
1578 * The {@link BasicFileAttributeView} type supports access to the basic
1579 * attributes of a file. Invoking this method to select a file attribute
1580 * view of that type will always return an instance of that class.
1581 *
1582 * <p> The {@code options} array may be used to indicate how symbolic links
1583 * are handled by the resulting file attribute view for the case that the
1584 * file is a symbolic link. By default, symbolic links are followed. If the
1585 * option {@link LinkOption#NOFOLLOW_LINKS NOFOLLOW_LINKS} is present then
1586 * symbolic links are not followed. This option is ignored by implementations
1587 * that do not support symbolic links.
1588 *
1589 * <p> <b>Usage Example:</b>
1590 * Suppose we want read or set a file's ACL, if supported:
1591 * <pre>
1592 * Path path = ...
1593 * AclFileAttributeView view = Files.getFileAttributeView(path, AclFileAttributeView.class);
1594 * if (view != null) {
1595 * List<AclEntry> acl = view.getAcl();
1596 * :
1597 * }
1598 * </pre>
1599 *
1600 *
1601 * @param path
1602 * the path to the file
1603 * @param type
1604 * the {@code Class} object corresponding to the file attribute view
1605 * @param options
1606 * options indicating how symbolic links are handled
1607 *
1608 * @return a file attribute view of the specified type, or {@code null} if
1609 * the attribute view type is not available
1610 */
1611 public static <V extends FileAttributeView> V getFileAttributeView(Path path,
1612 Class<V> type,
1613 LinkOption... options)
1614 {
1615 return provider(path).getFileAttributeView(path, type, options);
|
493 * stream's {@code close} method should be invoked after iteration is
494 * completed so as to free any resources held for the open directory.
495 *
496 * <p> Where the filter terminates due to an uncaught error or runtime
497 * exception then it is propagated to the {@link Iterator#hasNext()
498 * hasNext} or {@link Iterator#next() next} method. Where an {@code
499 * IOException} is thrown, it results in the {@code hasNext} or {@code
500 * next} method throwing a {@link DirectoryIteratorException} with the
501 * {@code IOException} as the cause.
502 *
503 * <p> When an implementation supports operations on entries in the
504 * directory that execute in a race-free manner then the returned directory
505 * stream is a {@link SecureDirectoryStream}.
506 *
507 * <p> <b>Usage Example:</b>
508 * Suppose we want to iterate over the files in a directory that are
509 * larger than 8K.
510 * <pre>
511 * DirectoryStream.Filter<Path> filter = new DirectoryStream.Filter<Path>() {
512 * public boolean accept(Path file) throws IOException {
513 * return (Files.size(file) > 8192L);
514 * }
515 * };
516 * Path dir = ...
517 * try (DirectoryStream<Path> stream = Files.newDirectoryStream(dir, filter)) {
518 * :
519 * }
520 * </pre>
521 *
522 * @param dir
523 * the path to the directory
524 * @param filter
525 * the directory stream filter
526 *
527 * @return a new and open {@code DirectoryStream} object
528 *
529 * @throws NotDirectoryException
530 * if the file could not otherwise be opened because it is not
531 * a directory <i>(optional specific exception)</i>
532 * @throws IOException
533 * if an I/O error occurs
1575 * attribute view defines type-safe methods to read or update the file
1576 * attributes. The {@code type} parameter is the type of the attribute view
1577 * required and the method returns an instance of that type if supported.
1578 * The {@link BasicFileAttributeView} type supports access to the basic
1579 * attributes of a file. Invoking this method to select a file attribute
1580 * view of that type will always return an instance of that class.
1581 *
1582 * <p> The {@code options} array may be used to indicate how symbolic links
1583 * are handled by the resulting file attribute view for the case that the
1584 * file is a symbolic link. By default, symbolic links are followed. If the
1585 * option {@link LinkOption#NOFOLLOW_LINKS NOFOLLOW_LINKS} is present then
1586 * symbolic links are not followed. This option is ignored by implementations
1587 * that do not support symbolic links.
1588 *
1589 * <p> <b>Usage Example:</b>
1590 * Suppose we want read or set a file's ACL, if supported:
1591 * <pre>
1592 * Path path = ...
1593 * AclFileAttributeView view = Files.getFileAttributeView(path, AclFileAttributeView.class);
1594 * if (view != null) {
1595 * List<AclEntry> acl = view.getAcl();
1596 * :
1597 * }
1598 * </pre>
1599 *
1600 *
1601 * @param path
1602 * the path to the file
1603 * @param type
1604 * the {@code Class} object corresponding to the file attribute view
1605 * @param options
1606 * options indicating how symbolic links are handled
1607 *
1608 * @return a file attribute view of the specified type, or {@code null} if
1609 * the attribute view type is not available
1610 */
1611 public static <V extends FileAttributeView> V getFileAttributeView(Path path,
1612 Class<V> type,
1613 LinkOption... options)
1614 {
1615 return provider(path).getFileAttributeView(path, type, options);
|