|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectjava.io.InputStream
messif.utility.DirectoryInputStream
public class DirectoryInputStream
This class provides a continous InputStream
over all
files from a given directory (and subdirectories if specified).
The file names can be filtered using a FileFilter
and
automatic decompression of GZIPInputStream
is used on
files that have "gz" suffix.
Constructor Summary | |
---|---|
DirectoryInputStream(java.util.Collection<java.io.File> dirs,
java.io.FileFilter filter,
boolean descendDirectories)
Creates a new DirectoryInputStream over files that match filter in dirs directories. |
|
DirectoryInputStream(java.io.File dir,
java.io.FileFilter filter,
boolean descendDirectories)
Creates a new DirectoryInputStream over files that match filter in the directory dir . |
|
DirectoryInputStream(java.lang.String dir,
java.io.FileFilter filter,
boolean descendDirectories)
Creates a new DirectoryInputStream over files that match filter in the directory dir . |
Method Summary | |
---|---|
int |
available()
|
void |
close()
|
void |
mark(int readlimit)
|
boolean |
markSupported()
|
static java.io.InputStream |
open(java.io.File path)
Open input stream for the specified path. |
static java.io.InputStream |
open(java.io.File path,
java.io.FileFilter filter)
Open input stream for the specified path. |
static java.io.InputStream |
open(java.lang.String path)
Open input stream for the specified path. |
int |
read()
|
int |
read(byte[] b)
|
int |
read(byte[] b,
int off,
int len)
|
void |
reset()
|
static java.util.Collection<java.io.File> |
searchFiles(java.util.Collection<java.io.File> files,
java.io.File dir,
java.io.FileFilter filter,
boolean descendDirectories)
Search the directory for files that match the filter. |
long |
skip(long n)
|
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public DirectoryInputStream(java.util.Collection<java.io.File> dirs, java.io.FileFilter filter, boolean descendDirectories) throws java.lang.NullPointerException, java.io.FileNotFoundException, java.io.IOException
filter
in dirs
directories.
dirs
- the collection of directories where to search for filesfilter
- the filter to apply on the files; all files are accepted if it is nulldescendDirectories
- if true, the subdirectories are descended and searched for matching files
java.lang.NullPointerException
- if one of the specified dirs
was null
java.io.FileNotFoundException
- if some of the specified dirs
was not found or was not a directory
java.io.IOException
- if there was a problem opening file from the directoriespublic DirectoryInputStream(java.io.File dir, java.io.FileFilter filter, boolean descendDirectories) throws java.lang.NullPointerException, java.io.FileNotFoundException, java.io.IOException
filter
in the directory dir
.
dir
- the directory where to search for filesfilter
- the filter to apply on the files; all files are accepted if it is nulldescendDirectories
- if true, the subdirectories are descended and searched for matching files
java.lang.NullPointerException
- if one of the specified dirs
was null
java.io.FileNotFoundException
- if some of the specified dirs
was not found or was not a directory
java.io.IOException
- if there was a problem opening file from the directoriespublic DirectoryInputStream(java.lang.String dir, java.io.FileFilter filter, boolean descendDirectories) throws java.lang.NullPointerException, java.io.FileNotFoundException, java.io.IOException
filter
in the directory dir
.
dir
- the directory where to search for filesfilter
- the filter to apply on the files; all files are accepted if it is nulldescendDirectories
- if true, the subdirectories are descended and searched for matching files
java.lang.NullPointerException
- if one of the specified dirs
was null
java.io.FileNotFoundException
- if some of the specified dirs
was not found or was not a directory
java.io.IOException
- if there was a problem opening file from the directoriesMethod Detail |
---|
public static java.io.InputStream open(java.lang.String path) throws java.io.FileNotFoundException, java.io.IOException
path
is null, empty or "-", the System.in
is returned.path
is a directory, all the files in this directory and its subdirectories
will be merged into a single input stream
that is returned.path
contains wildcards (*, ?, [ab-z] are supported)
in the last component, the begining is treated as the directory name and the last
component as the wildcard for the filenames. FileInputStream
is returned.GZIP stream decompression
is automatically used.
path
- the path to open
java.io.FileNotFoundException
- if the specified path
was not found
java.io.IOException
- if there was a problem opening file from the directoriespublic static java.io.InputStream open(java.io.File path) throws java.io.FileNotFoundException, java.io.IOException
path
is null, the System.in
is returned.
If the path
is a directory, all the files in this directory and its subdirectories
will be merged into a single input stream
that is returned.
Otherwise, a FileInputStream
is returned.
If any of the file names end with "gz", GZIP stream decompression
is automatically used.
path
- the path to open
java.io.FileNotFoundException
- if the specified path
was not found
java.io.IOException
- if there was a problem opening file from the directoriespublic static java.io.InputStream open(java.io.File path, java.io.FileFilter filter) throws java.io.FileNotFoundException, java.io.IOException
path
is null, the System.in
is returned.
If the path
is a directory, all the files in this directory and its subdirectories
will be merged into a single input stream
that is returned.
Otherwise, a FileInputStream
is returned.
If any of the file names end with "gz", GZIP stream decompression
is automatically used.
path
- the path to openfilter
- the filter to apply on the files; all files are accepted if it is null
java.io.FileNotFoundException
- if the specified path
was not found
java.io.IOException
- if there was a problem opening file from the directoriespublic static java.util.Collection<java.io.File> searchFiles(java.util.Collection<java.io.File> files, java.io.File dir, java.io.FileFilter filter, boolean descendDirectories) throws java.io.FileNotFoundException, java.lang.NullPointerException
descendDirectories
parameter is true,
the subdirectories are descended and searched too.
The found files are added to the files
collection.
There is no guarantee that the files in the resulting collection will appear
in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.
files
- the collection that receives the files found; if null, a new ArrayList
is createddir
- the directory to search for filesfilter
- the filter to apply on the files; all files are accepted if it is nulldescendDirectories
- if true, the subdirectories are descended and searched for matching files
files
argument
java.io.FileNotFoundException
- if the specified dir
was not found or it is not a directory
java.lang.NullPointerException
- if the specified dir
was nullpublic int read() throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(byte[] b) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public int read(byte[] b, int off, int len) throws java.io.IOException
read
in class java.io.InputStream
java.io.IOException
public long skip(long n) throws java.io.IOException
skip
in class java.io.InputStream
java.io.IOException
public int available() throws java.io.IOException
available
in class java.io.InputStream
java.io.IOException
public void close() throws java.io.IOException
close
in interface java.io.Closeable
close
in class java.io.InputStream
java.io.IOException
public void mark(int readlimit)
mark
in class java.io.InputStream
public void reset() throws java.io.IOException
reset
in class java.io.InputStream
java.io.IOException
public boolean markSupported()
markSupported
in class java.io.InputStream
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |