NIO2 API

org.classpath.icedtea.java.nio.file
Class SimpleFileVisitor<T extends FileRef>

java.lang.Object
  extended by org.classpath.icedtea.java.nio.file.SimpleFileVisitor<T>
Type Parameters:
T - The type of reference to the files
All Implemented Interfaces:
FileVisitor<T>

public class SimpleFileVisitor<T extends FileRef>
extends Object
implements FileVisitor<T>

A simple visitor of files with default behavior to visit all files and to re-throw I/O errors.

Methods in this class may be overridden subject to their general contract.

Since:
1.7

Constructor Summary
protected SimpleFileVisitor()
          Initializes a new instance of this class.
 
Method Summary
 FileVisitResult postVisitDirectory(T dir, IOException exc)
          Invoked for a directory after entries in the directory, and all of their descendants, have been visited.
 FileVisitResult preVisitDirectory(T dir)
          Invoked for a directory before entries in the directory are visited.
 FileVisitResult preVisitDirectoryFailed(T dir, IOException exc)
          Invoked for a directory that could not be opened.
 FileVisitResult visitFile(T file, BasicFileAttributes attrs)
          Invoked for a file in a directory.
 FileVisitResult visitFileFailed(T file, IOException exc)
          Invoked for a file when its basic file attributes could not be read.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

SimpleFileVisitor

protected SimpleFileVisitor()
Initializes a new instance of this class.

Method Detail

preVisitDirectory

public FileVisitResult preVisitDirectory(T dir)
Invoked for a directory before entries in the directory are visited.

Unless overridden, this method returns CONTINUE.

Specified by:
preVisitDirectory in interface FileVisitor<T extends FileRef>
Parameters:
dir - A reference to the directory
Returns:
the visit result

preVisitDirectoryFailed

public FileVisitResult preVisitDirectoryFailed(T dir,
                                               IOException exc)
Invoked for a directory that could not be opened.

Unless overridden, this method throws IOError with the I/O exception as cause.

Specified by:
preVisitDirectoryFailed in interface FileVisitor<T extends FileRef>
Parameters:
dir - A reference to the directory
exc - The I/O exception thrown from the attempt to open the directory
Returns:
the visit result
Throws:
IOError - With the I/O exception thrown when the attempt to open the directory failed

visitFile

public FileVisitResult visitFile(T file,
                                 BasicFileAttributes attrs)
Invoked for a file in a directory.

Unless overridden, this method returns CONTINUE.

Specified by:
visitFile in interface FileVisitor<T extends FileRef>
Parameters:
file - A reference to the file
attrs - The file's basic attributes
Returns:
the visit result

visitFileFailed

public FileVisitResult visitFileFailed(T file,
                                       IOException exc)
Invoked for a file when its basic file attributes could not be read.

Unless overridden, this method throws IOError with the I/O exception as cause.

Specified by:
visitFileFailed in interface FileVisitor<T extends FileRef>
Parameters:
file - A reference to the file
exc - The I/O exception thrown from the attempt to read the file attributes
Returns:
the visit result
Throws:
IOError - With the I/O exception thrown when the attempt to read the file attributes failed

postVisitDirectory

public FileVisitResult postVisitDirectory(T dir,
                                          IOException exc)
Invoked for a directory after entries in the directory, and all of their descendants, have been visited.

Unless overridden, this method returns CONTINUE if the directory iteration completes without an I/O exception; otherwise this method throws IOError with the I/O exception as cause.

Specified by:
postVisitDirectory in interface FileVisitor<T extends FileRef>
Parameters:
dir - A reference to the directory
exc - null if the iteration of the directory completes without an error; otherwise the I/O exception that caused the iteration of the directory to complete prematurely
Returns:
the visit result
Throws:
IOError - If iteration of the directory completed prematurely due to an I/O error

NIO2 API

Copyright © 2007, 2011, Oracle and/or its affiliates. All rights reserved.