java.lang.Object
org.bzdev.io.DelayedFileInputStream
Class to provide delayed opening of a file input stream.
This class is intended to allow classes that have permission to
open a file for reading to delay opening the file until a later
time. The file may be opened by a class that has weaker permissions.
An example of when this class may be useful is when an application has to open a long list of files, perhaps passed to the application on the command line, and these files have to be processed later (the original use case was one in which a security manager was installed, but security managers do not exist in later versions of Java). Each java virtual machine has a limit on the number of files that can be simultaneously opened, so opening all the files (if there are enough of them) and then processing them will not work.
-
Constructor Summary
ConstructorsConstructorDescriptionDelayedFileInputStream
(File file) Constructor given a file.DelayedFileInputStream
(String name) Constructor given a file name. -
Method Summary
-
Constructor Details
-
DelayedFileInputStream
Constructor given a file name.- Parameters:
name
- the name of the file to open for reading- Throws:
FileNotFoundException
- the file could not be found
-
DelayedFileInputStream
Constructor given a file.- Parameters:
file
- the file to open for reading.- Throws:
FileNotFoundException
- the file could not be found
-
-
Method Details
-
open
Open the file specified by a constructor. This method can be called at most one time. The file actually opened is the file with the same canonical path name as the file passed to the constructor.- Returns:
- the input stream for reading the file
- Throws:
FileNotFoundException
- the file could not be found
-