Java Reference
In-Depth Information
Returns the available filesystem roots, that is, roots of local
hierarchical file systems. Windows platforms, for example,
have a root directory for each active drive;
UNIX
platforms
have a single
/
root directory. If none are available, the array
has zero elements.
The methods
listFiles()and listFiles(FilenameFilter
) are analogous to
list()and list(FilenameFilter)
, but return arrays of
File
objects instead
of arrays of strings. The method
listFiles(FileFilter)
is analogous to
the
list
that uses a
FilenameFilter
.
Three methods relate primarily to temporary files (sometimes called
"scratch files")those files you need to create during a run of your pro-
gram for storing data, or to pass between passes of your computation,
but which are not needed after your program is finished.
public static File
createTempFile(String prefix, String suffix, File
directory)
tHRows IOException
Creates a new empty file in the specified directory, using the
given prefix and suffix strings to generate its name. If this
method returns successfully then it is guaranteed that the
file denoted by the returned abstract pathname did not ex-
ist before this method was invoked, and neither this meth-
od nor any of its variants will return the same abstract path-
name again in the current invocation of the virtual machine.
The
prefix
argument must be at least three characters long,
otherwise an
IllegalArgumentException
is thrown. It is recom-
mended that the prefix be a short, meaningful string such as
"hjb"
or
"mail"
. The
suffix
argument may be
null
, in which
case the suffix
".tmp"
will be used. Note that since there is
no predefined separator between the file name and the suf-
fix, any separator, such as
'.'
, must be part of the suffix.
If the
directory
argument is
null
then the system-depend-
ent default temporary-file directory will be used. The default
temporary-file directory is specified by the system property
java.io.tmpdir
.