java.io.File
, a File
is essentially an
"abstract pathname" which may or may not denote an actual file on the file
system. Methods createNewFile
,
mkdir
, mkdirs
, and remove
are provided
to actually manipulate physical files.
File access is limited to certain virtual directories. These directories are a subset of those accessible through WebDAV. As a result of this restriction, pathnames must be one of the following forms:
/TEMP(/...)
/IMPEX(/...)
/REALMDATA(/...)
/CATALOGS/[Catalog Name](/...)
/LIBRARIES/[Library Name](/...)
The files are stored in a shared file system where multiple processes could access the same file. The programmer has to make sure no more than one process writes to a file at a given time.
This class provides other useful methods for listing the children of a directory and for working with zip files.
Note: when this class is used with sensitive data, be careful in persisting sensitive information.
For performance reasons no more than 100,000 files (regular files and directories) should be stored in a directory.
File
.
This value will be the same regardless of which constructor was
used to create this File
.File
.
File
.File
representing a directory for the specified root directory type.File
objects denoting the files and directories in the directory denoted by this object that satisfy the specified filter.File
from the given absolute file path in the
file namespace. If the specified path is not a valid accessible path,
an exception will be thrown.
The passed path should use the forward slash '/' as the path separator and begin with a leading slash. However, if a leading slash is not provided, or the backslash character is used as the separator, these problems will be fixed. The normalized value will then be returned by getFullPath().
File
.
This value will be the same regardless of which constructor was
used to create this File
.File
representing a directory for the specified
root directory type. If the root directory
type is CATALOGS or LIBRARIES, then an additional argument representing
the specific catalog or library must be provided. Otherwise, no
additional arguments are needed.File
.
If this object does not denote a directory, then this method returns
null
. Otherwise an array of strings is returned, one for
each file or directory in the directory. Names denoting the directory
itself and the directory's parent directory are not included in the
result. Each string is a file name rather than a complete path.
There is no guarantee that the name strings in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order.
File
. The array will be empty if the directory is empty. Returns null
if this File
does not denote a directory.
File
objects in the directory denoted
by this File
.
If this File
does not denote a directory, then this method
returns null
. Otherwise an array of File
objects is returned, one for each file or directory in the directory.
Files denoting the directory itself and the directory's parent directory
are not included in the result.
There is no guarantee that the files in the resulting array will appear in any specific order; they are not, in particular, guaranteed to appear in alphabetical order. Example usage:
// Assume "foo" is an accessible directory.
var this_directory : dw.io.File = new File("foo");
// Find all files in directory foo, one level "down".
// listFiles() will not traverse subdirectories.
var folder : dw.util.List = this_directory.listFiles();
var first_element : dw.io.File = folder[0];
function modification_comparison(lhs : File, rhs : File)
{
return lhs.lastModified() < rhs.lastModified();
}
function lexigraphic_comparison(lhs: File, rhs : File)
{
return lhs.getName() < rhs.getName();
}
var time_ordered_folder : dw.util.ArrayList = folder.sort(modification_comparison);
var alphabetic_folder : dw.util.ArrayList = folder.sort(lexigraphic_comparison);
File
objects or null
if this is not a directory.
File
objects denoting the files and
directories in the directory denoted by this object that satisfy the
specified filter. The behavior of this method is the same as that of the
listFiles()
method, except that the files in the
returned array must satisfy the filter. The filter is a Javascript
function which accepts one argument, a File
, and returns
true or false depending on whether the file meets the filter conditions.
If the given filter
is null
then all files
are accepted. Otherwise, a file satisfies the filter if and only if the
filter returns true
. Example usage:
// Assume "foo" is an accessible directory.
var this_directory : dw.io.File = new File("foo");
function longer_than_3(candidate : dw.io.File)
{
return candidate.getName().length > 3;
}
// Find all files in directory foo, one level "down",
// such that the filename is longer than 3 characters.
var folder_long_names : dw.util.List = this_directory.listFiles(longer_than_3);
File
argument and returns true
or false
.
File
objects or null
if this is not a directory