Class IFSJavaFile
- java.lang.Object
-
- java.io.File
-
- com.ibm.as400.access.IFSJavaFile
-
- All Implemented Interfaces:
- java.io.Serializable, java.lang.Comparable<java.io.File>
public class IFSJavaFile extends java.io.File implements java.io.Serializable
Represents an object in the IBM i integrated file system.
IFSJavaFile extends the java.io.File class and allows programs to be written for the java.io.File interface and still access the IBM i integrated file system. IFSFile should be considered as an alternate to java.io.File class.When should IFSJavaFile be used?
- IFSJavaFile should be used when a portable interface, compatible with java.io.File, is needed. For example, you have written code that accesses the native file system. Now you want to move the design to a networked file system. More particularly, you need to move the code to the IBM i integrated file system. When a program is being ported and needs to use the IBM i integrated file system, IFSJavaFile is a good choice. IFSJavaFile also provides SecurityManager features defined in java.io.File.
-
If you need to take full advantage of the IBM i integrated file
system,
IFSFile
is more useful. IFSFile is written to handle more of the specific IBM i integrated file system details. - java.io.File can be used to access the IBM i file system if you use a product like IBM i Access for Windows to map a local drive to the IBM i integrated file system.
Notes:
- IFSJavaFile is designed to be used with
IFSFileInputStream
andIFSFileOutputStream
. It does not support java.io.FileInputStream and java.io.FileOutputStream. - IFSJavaFile cannot override createTempFile because java.io.File defines createTempFile as a static method.
- IFSJavaFile cannot override deleteOnExit because the Java Virtual Machine does nothing to indicate when it is preparing to exit.
- IFSJavaFile is designed to look more like java.io.File than IFSFile. It is designed to enable a plug-in fit for previously written java.io.File code.
- IFSJavaFile always implements a SecurityManager using IBM i security. The SecurityManager provides authority checks. It throws security exceptions when illegal access attempts are made.
The following example demonstrates the use of IFSJavaFile. It shows how a few lines of platform specific code enable the creation of a file on either the IBM i system or the local client.
int location = ON_THE_SERVER; // on the IBM i system java.io.File file = null; java.io.OutputStream os = null;
if (location == ON_THE_SERVER) file = new IFSJavaFile(new AS400("enterprise"), path); // Work with the file on the system "enterprise". else file = new java.io.File(path); // Work with the file on the local file system.
if (file.exists()) System.out.println("Length: " + file.length()); // Determine the file size. else System.out.println("File " + file.getName() + " not found");
// Delete the file. This should be done before creating an output stream. if (file.delete() == false) System.err.println("Unable to delete file."); // Display the error message.
if (location == ON_THE_SERVER) os = (OutputStream)new IFSFileOutputStream((IFSJavaFile)file); else os = new FileOutputStream(file);
writeData(file, os); os.close();
void writeData(java.io.File file, java.io.OutputStream os) throws IOException { // Determine the parent directory of the file. System.out.println("Directory: " + file.getParent());
// Determine the name of the file. System.out.println("Name: " + file.getName());
// Determine when the file was last modified. System.out.println("Date: " + new Date(file.lastModified()));
System.out.println("Writing Data"); for (int i = 0; i < 256; i++) os.write((byte)i); }- See Also:
IFSFile
,IFSFileInputStream
,IFSFileOutputStream
, Serialized Form
-
-
Constructor Summary
Constructors Constructor and Description IFSJavaFile()
Creates a default IFSJavaFile instance.IFSJavaFile(AS400 system, IFSJavaFile directory, java.lang.String name)
Creates a new IFSJavaFile instance for the specified system, from a parent abstract pathname and a child pathname string.IFSJavaFile(AS400 system, java.lang.String path)
Creates a new IFSJavaFile instance for the specified system, using a file pathname string.IFSJavaFile(AS400 system, java.lang.String path, java.lang.String name)
Creates a new IFSJavaFile instance for the specified system, from a parent pathname string and a child pathname string.IFSJavaFile(IFSFile file)
Creates a new IFSJavaFile instance from an IFSFile object.IFSJavaFile(IFSJavaFile directory, java.lang.String name)
Creates a new IFSJavaFile instance from a parent abstract pathname and a child pathname string.
-
Method Summary
Methods Modifier and Type Method and Description boolean
canExecute()
Tests whether the application can execute the file denoted by this abstract pathname.boolean
canRead()
Indicates if the program can read from the file denoted by this abstract pathname.boolean
canWrite()
Indicates if the program can write to the file denoted by this abstract pathname.int
compareTo(java.io.File file)
Compares the path of IFSJavaFile with aFile
's path.int
compareTo(IFSFile file)
Compares the path of IFSJavaFile with aIFSFile
's path.int
compareTo(IFSJavaFile file)
Compares the paths of two IFSJavaFiles.boolean
createNewFile()
Atomically create a new, empty file.boolean
delete()
Deletes the IFSJavaFile.boolean
equals(java.lang.Object obj)
Compares this IFSJavaFile against the specified object.boolean
exists()
Indicates if the IFSJavaFile exists.java.io.File
getAbsoluteFile()
Returns An IFSJavaFile object based on the absolute path name of the current object.java.lang.String
getAbsolutePath()
Returns the absolute path name of the IFSJavaFile.java.io.File
getCanonicalFile()
Returns An IFSJavaFile object based on the canonical path name of the current object.java.lang.String
getCanonicalPath()
Returns the path name in canonical form of IFSJavaFile path.long
getFreeSpace()
Returns the number of unallocated bytes in the partition named by this abstract path name.java.lang.String
getName()
Returns the name of the IFSJavaFile.java.lang.String
getParent()
Returns the parent directory of the IFSJavaFile.java.io.File
getParentFile()
Returns an IFSJavaFile object that represents the parent of the current object.java.lang.String
getPath()
Returns the path name of the IFSJavaFile.int
getPatternMatching()
Returns the pattern-matching behavior used when files are listed by any of the list() or listFiles() methods.AS400
getSystem()
Returns the system that this object references.long
getTotalSpace()
Returns the size of the partition named by this abstract pathname.long
getUsableSpace()
Returns the number of bytes available to this virtual machine on the partition named by this abstract pathname.int
hashCode()
Computes a hashcode for this object.boolean
isAbsolute()
Indicates if the path name of this IFSJavaFile is an absolute path name.boolean
isDirectory()
Indicates if the IFSJavaFile is a directory.boolean
isFile()
Indicates if the IFSJavaFile is a "normal" file.boolean
isHidden()
Indicates if the IFSJavaFile is hidden.long
lastModified()
Indicates the time that the IFSJavaFile was last modified.long
length()
Indicates the length of this IFSJavaFile.java.lang.String[]
list()
Lists the files in this IFSJavaFile directory.java.lang.String[]
list(java.io.FilenameFilter filter)
Lists the files in this IFSJavaFile directory that satisfy filter.java.lang.String[]
list(IFSFileFilter filter)
Lists the files in the IFSJavaFile directory that satisfy file name filter.java.lang.String[]
list(IFSFileFilter filter, java.lang.String pattern)
Lists the files in this IFSJavaFile directory that satisfy filter and pattern.java.lang.String[]
list(java.lang.String pattern)
Lists the files in this IFSJavaFile directory that match pattern.java.io.File[]
listFiles()
Lists the files in this IFSJavaFile directory.java.io.File[]
listFiles(java.io.FileFilter filter)
Lists the files in this IFSJavaFile directory that satisfy filter.java.io.File[]
listFiles(java.io.FilenameFilter filter)
Lists the files in this IFSJavaFile directory that satisfy filter.java.io.File[]
listFiles(IFSFileFilter filter)
Lists the files in the IFSJavaFile directory that satisfy file name filter.java.io.File[]
listFiles(IFSFileFilter filter, java.lang.String pattern)
Lists the files in this IFSJavaFile directory that satisfy filter and pattern.java.io.File[]
listFiles(java.lang.String pattern)
Lists the files in this IFSJavaFile directory that match pattern.static java.io.File[]
listRoots()
Lists the file system roots for the integrated file system of the IBM i system.boolean
mkdir()
Creates a directory whose path name is specified by this IFSJavaFile.boolean
mkdirs()
Creates a directory whose path name is specified by this IFSJavaFile, including any necessary parent directories.boolean
renameTo(java.io.File dest)
Renames the IFSJavaFile to have the path name of dest.boolean
renameTo(IFSJavaFile dest)
Renames the IFSJavaFile to have the path name of dest.boolean
setExecutable(boolean executable)
A convenience method to set the owner's execute permission for this abstract pathname.boolean
setExecutable(boolean executable, boolean ownerOnly)
Sets the owner's or everybody's execute permission for this abstract pathname.boolean
setLastModified(long time)
Sets the last modified time of the file named by this IFSJavaFile object.boolean
setLength(int length)
Sets the length of the file named by this IFSJavaFile object.boolean
setPath(java.lang.String path)
Sets the path for this IFSJavaFile.void
setPatternMatching(int patternMatching)
Sets the pattern-matching behavior used when files are listed by any of the list() or listFiles() methods.boolean
setReadable(boolean readable)
A convenience method to set the owner's read permission for this abstract pathname.boolean
setReadable(boolean readable, boolean ownerOnly)
Sets the owner's or everybody's read permission for this abstract pathname.boolean
setReadOnly()
Marks the file named by this IFSJavaFile object so that only read operations are allowed.boolean
setSystem(AS400 system)
Sets the system.boolean
setWritable(boolean writable)
A convenience method to set the owner's write permission for this abstract pathname.boolean
setWritable(boolean writable, boolean ownerOnly)
Sets the owner's or everybody's write permission for this abstract pathname.java.lang.String
toString()
Returns a string representation of this object.java.net.URL
toURL()
Converts the abstract path name into afile:
URL.
-
-
-
Constructor Detail
-
IFSJavaFile
public IFSJavaFile()
Creates a default IFSJavaFile instance.
-
IFSJavaFile
public IFSJavaFile(AS400 system, java.lang.String path)
Creates a new IFSJavaFile instance for the specified system, using a file pathname string.- Parameters:
system
- The system that contains the IFSJavaFile.path
- The file path name where the IFSJavaFile is or will be stored.
-
IFSJavaFile
public IFSJavaFile(AS400 system, java.lang.String path, java.lang.String name)
Creates a new IFSJavaFile instance for the specified system, from a parent pathname string and a child pathname string.- Parameters:
system
- The system that contains the IFSJavaFile.path
- The file path name where the IFSJavaFile is or will be stored.name
- The name of the IFSJavaFile object.
-
IFSJavaFile
public IFSJavaFile(IFSJavaFile directory, java.lang.String name)
Creates a new IFSJavaFile instance from a parent abstract pathname and a child pathname string.The directory argument cannot be null. The constructed IFSJavaFile instance uses the following settings taken from directory:
- system
- path
- Parameters:
directory
- The directory where the IFSJavaFile is or will be stored.name
- The name of the IFSJavaFile object.
-
IFSJavaFile
public IFSJavaFile(AS400 system, IFSJavaFile directory, java.lang.String name)
Creates a new IFSJavaFile instance for the specified system, from a parent abstract pathname and a child pathname string.- Parameters:
system
- The system that contains the IFSJavaFile.directory
- The directory where the IFSJavaFile is or will be stored.name
- The name of the IFSJavaFile object.
-
IFSJavaFile
public IFSJavaFile(IFSFile file)
Creates a new IFSJavaFile instance from an IFSFile object.- Parameters:
file
- An IFSFile object.
-
-
Method Detail
-
canExecute
public boolean canExecute() throws java.lang.SecurityException
Tests whether the application can execute the file denoted by this abstract pathname. This method is supported for IBM i V5R1 and higher. For older releases, it simply returns false. If the user profile has *ALLOBJ special authority (and system is V5R1 or higher), this method always returns true.- Overrides:
canExecute
in classjava.io.File
- Returns:
- true if and only if the abstract pathname exists and the application is allowed to execute the file. For consistency with the behavior of java.io.File on IBM i JVM's: If a security error occurs simply because the user profile isn't allowed to access the file, the error is traced and false is returned.
- Throws:
java.lang.SecurityException
- If an unanticipated security error occurs.
-
canRead
public boolean canRead() throws java.lang.SecurityException
Indicates if the program can read from the file denoted by this abstract pathname.- Overrides:
canRead
in classjava.io.File
- Returns:
- true if and only if the abstract pathname exists and the application is allowed to read the file. For consistency with the behavior of java.io.File on IBM i JVM's: If a security error occurs simply because the user profile isn't allowed to access the file, the error is traced and false is returned.
- Throws:
java.lang.SecurityException
- If an unanticipated security error occurs.
-
canWrite
public boolean canWrite() throws java.lang.SecurityException
Indicates if the program can write to the file denoted by this abstract pathname.- Overrides:
canWrite
in classjava.io.File
- Returns:
- true if and only if the abstract pathname exists and the application is allowed to write the file. For consistency with the behavior of java.io.File on IBM i JVM's: If a security error occurs simply because the user profile isn't allowed to access the file, the error is traced and false is returned.
- Throws:
java.lang.SecurityException
- If an unanticipated security error occurs.
-
compareTo
public int compareTo(IFSJavaFile file)
Compares the paths of two IFSJavaFiles.The following examples demonstrate the use of this method:
In this example, returnCode would be less than
0
because the path offile
is less than the path offile2
.IFSJavaFile file = new IFSJavaFile(new AS400("enterprise"), path); IFSJavaFile file2 = new IFSJavaFile(new AS400("enterprise"), path + "\\extra");
int returnCode = file.compareTo(file2);In this example, returnCode would be greater than
0
because the path offile
is greater than the path offile2
.IFSJavaFile file = new IFSJavaFile(new AS400("enterprise"), path + "\\extra"); IFSJavaFile file2 = new IFSJavaFile(new AS400("enterprise"), path);
int returnCode = file.compareTo(file2);In this example, returnCode would be less than
0
because the path offile
is less than the path offile2
.IFSJavaFile file = new IFSJavaFile(new AS400("enterprise"), "\\QSYS.LIB\\herlib"); IFSJavaFile file2 = new IFSJavaFile(new AS400("enterprise"), "\\QSYS.LIB\\hislib");
int returnCode = file.compareTo(file2);Note:
The comparison is case sensitive.- Parameters:
file
- The IFSJavaFile to be compared.- Returns:
0
if this IFSJavaFile path equalsfile
's path; a value less than0
if this IFSJavaFile path is less than thefile
's path; and a value greater than0
if this IFSJavaFile path is greater than thefile's
path.- Since:
- JDK1.2
-
compareTo
public int compareTo(java.io.File file)
Compares the path of IFSJavaFile with aFile
's path.Note:
The comparison is case sensitive.- Specified by:
compareTo
in interfacejava.lang.Comparable<java.io.File>
- Overrides:
compareTo
in classjava.io.File
- Parameters:
file
- TheFile
to be compared.- Returns:
0
if this IFSJavaFile path equals the argument's path; a value less than0
if this IFSJavaFile path is less than the argument's path; and a value greater than0
if this IFSJavaFile path is greater than the argument's path.- Since:
- JDK1.2
-
compareTo
public int compareTo(IFSFile file)
Compares the path of IFSJavaFile with aIFSFile
's path.Note:
The comparison is case sensitive.- Parameters:
file
- TheIFSFile
to be compared.- Returns:
0
if this IFSJavaFile path equals the argument's path; a value less than0
if this IFSJavaFile path is less than the argument's path; and a value greater than0
if this IFSJavaFile path is greater than the argument's path.- Since:
- JDK1.2
-
createNewFile
public boolean createNewFile() throws java.io.IOException
Atomically create a new, empty file. The file is created if and only if the file does not yet exist. The check for existence and the file creation is a single atomic operation.- Overrides:
createNewFile
in classjava.io.File
- Returns:
- true if the file is created, false otherwise.
- Throws:
java.io.IOException
- If an I/O error occurs while communicating with the IBM i system.
-
delete
public boolean delete() throws java.lang.SecurityException
Deletes the IFSJavaFile. If the target is a directory, it must be empty for deletion to succeed.- Overrides:
delete
in classjava.io.File
- Returns:
true
if the file is successfully deleted;false
otherwise.- Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
equals
public boolean equals(java.lang.Object obj)
Compares this IFSJavaFile against the specified object. Returnstrue
if and only if the argument is not null and is an IFSJavaFile object whose path name is equal to the path name of this IFSJavaFile, and system names of the objects are equal.- Overrides:
equals
in classjava.io.File
- Parameters:
obj
- The object to compare with.- Returns:
true
if the objects are the same;false
otherwise.
-
exists
public boolean exists() throws java.lang.SecurityException
Indicates if the IFSJavaFile exists.- Overrides:
exists
in classjava.io.File
- Returns:
true
if the file specified by this object exists;false
otherwise.- Throws:
java.lang.SecurityException
- If the user is denied read access to the file.java.lang.SecurityException
- If the user is denied access to the file.
-
getAbsoluteFile
public java.io.File getAbsoluteFile()
Returns An IFSJavaFile object based on the absolute path name of the current object. If the system property is set, it is copied to the returned object.- Overrides:
getAbsoluteFile
in classjava.io.File
- Returns:
- an IFSJavaFile object based on the absolute path name of the current object.
- See Also:
getAbsolutePath()
-
getAbsolutePath
public java.lang.String getAbsolutePath()
Returns the absolute path name of the IFSJavaFile. This is the full path starting at the root directory.- Overrides:
getAbsolutePath
in classjava.io.File
- Returns:
- The absolute path name for this IFSJavaFile. All paths are absolute paths in the integrated file system.
- See Also:
isAbsolute()
-
getCanonicalFile
public java.io.File getCanonicalFile() throws java.io.IOException
Returns An IFSJavaFile object based on the canonical path name of the current object. If the system property is set, it is copied to the returned object.- Overrides:
getCanonicalFile
in classjava.io.File
- Returns:
- an IFSJavaFile object based on the canonical path name of the current object.
- Throws:
java.io.IOException
- If an I/O error occurs while communicating with the IBM i system.- See Also:
getCanonicalPath()
-
getCanonicalPath
public java.lang.String getCanonicalPath() throws java.io.IOException
Returns the path name in canonical form of IFSJavaFile path. This is the full path starting at the root directory.- Overrides:
getCanonicalPath
in classjava.io.File
- Returns:
- The canonical path name for this IFSJavaFile.
- Throws:
java.io.IOException
- If an I/O error occurs while communicating with the IBM i system.
-
getFreeSpace
public long getFreeSpace() throws java.lang.SecurityException
Returns the number of unallocated bytes in the partition named by this abstract path name.The returned number of unallocated bytes is a hint, but not a guarantee, that it is possible to use most or any of these bytes. The number of unallocated bytes is most likely to be accurate immediately after this call. It is likely to be made inaccurate by any external I/O operations including those made on the system outside of this virtual machine. This method makes no guarantee that write operations to this file system will succeed.
- Overrides:
getFreeSpace
in classjava.io.File
- Returns:
- The number of unallocated bytes on the partition; or 0L if the abstract pathname does not name a partition. This value will be less than or equal to the total file system size returned by getTotalSpace().
- Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
getTotalSpace
public long getTotalSpace() throws java.lang.SecurityException
Returns the size of the partition named by this abstract pathname.- Overrides:
getTotalSpace
in classjava.io.File
- Returns:
- The size, in bytes, of the partition; or 0L if this abstract pathname does not name a partition.
- Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
getUsableSpace
public long getUsableSpace() throws java.lang.SecurityException
Returns the number of bytes available to this virtual machine on the partition named by this abstract pathname. When possible, this method checks for write permissions and other operating system restrictions and will therefore usually provide a more accurate estimate of how much new data can actually be written than getFreeSpace().The returned number of available bytes is a hint, but not a guarantee, that it is possible to use most or any of these bytes. The number of unallocated bytes is most likely to be accurate immediately after this call. It is likely to be made inaccurate by any external I/O operations including those made on the system outside of this virtual machine. This method makes no guarantee that write operations to this file system will succeed.
Note: If the user profile has a "maximum storage allowed" setting of *NOMAX, then getUsableSpace() returns the same value as
getFreeSpace()
.- Overrides:
getUsableSpace
in classjava.io.File
- Returns:
- The number of available bytes on the partition; or 0L if the abstract pathname does not name a partition.
- Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
getName
public java.lang.String getName()
Returns the name of the IFSJavaFile. The name is everything in the path name after the last occurrence of the separator character.The following example demonstrates the use of this method:
In this example, fileName would equal "file.dat".
String path = "\\path\\file.dat"; IFSJavaFile file = new IFSJavaFile(new AS400("enterprise"), path);
String fileName = file.getName();- Overrides:
getName
in classjava.io.File
- Returns:
- The name (without any directory components) of this IFSJavaFile.
-
getParent
public java.lang.String getParent()
Returns the parent directory of the IFSJavaFile. The parent directory is everything in the path name before the last occurrence of the separator character, or null if the separator character does not appear in the path name.The following example demonstrates the use of this method:
In this example, parentPath would equal "\test".
String path = "\\test\\path"; IFSJavaFile file = new IFSJavaFile(new AS400("enterprise"), path);
String parentPath = file.getParent();- Overrides:
getParent
in classjava.io.File
- Returns:
- The parent directory if one exists; null otherwise.
- See Also:
getParentFile()
-
getParentFile
public java.io.File getParentFile()
Returns an IFSJavaFile object that represents the parent of the current object. The parent is the path name before the last occurrence of the separator character. Null is returned if the separator character does not appear in the path or the current object is the file system root. If the system property is set, it is also copied to the returned object.- Overrides:
getParentFile
in classjava.io.File
- Returns:
- an IFSJavaFile object representing the parent directory if one exists; null otherwise.
- See Also:
getParent()
-
getPath
public java.lang.String getPath()
Returns the path name of the IFSJavaFile.The following example demonstrates the use of this method:
In this example, thePath would equal "\test\path" the same value as path.
String path = "\\test\\path"; IFSJavaFile file = new IFSJavaFile(new AS400("enterprise"), path);
String thePath = file.getPath();- Overrides:
getPath
in classjava.io.File
- Returns:
- The file path name.
-
getPatternMatching
public int getPatternMatching() throws java.io.IOException
Returns the pattern-matching behavior used when files are listed by any of the list() or listFiles() methods. The default is PATTERN_POSIX.- Returns:
- Either
PATTERN_POSIX
,PATTERN_POSIX_ALL
, orPATTERN_OS2
- Throws:
java.io.IOException
- If an error occurs while communicating with the system.
-
getSystem
public AS400 getSystem()
Returns the system that this object references.- Returns:
- The system object.
-
hashCode
public int hashCode()
Computes a hashcode for this object.- Overrides:
hashCode
in classjava.io.File
- Returns:
- A hash code value for this object.
-
isAbsolute
public boolean isAbsolute()
Indicates if the path name of this IFSJavaFile is an absolute path name.- Overrides:
isAbsolute
in classjava.io.File
- Returns:
true
if the path name specification is absolute;false
otherwise.
-
isDirectory
public boolean isDirectory() throws java.lang.SecurityException
Indicates if the IFSJavaFile is a directory.- Overrides:
isDirectory
in classjava.io.File
- Returns:
true
if the IFSJavaFile exists and is a directory;false
otherwise.- Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
isFile
public boolean isFile() throws java.lang.SecurityException
Indicates if the IFSJavaFile is a "normal" file.
A file is "normal" if it is not a directory or a container of other objects.- Overrides:
isFile
in classjava.io.File
- Returns:
true
if the specified file exists and is a "normal" file;false
otherwise.- Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
isHidden
public boolean isHidden() throws java.lang.SecurityException
Indicates if the IFSJavaFile is hidden. On the IBM i system, a file is hidden if its hidden attribute is set.- Overrides:
isHidden
in classjava.io.File
- Returns:
true
if the file is hidden;false
otherwise.- Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
lastModified
public long lastModified() throws java.lang.SecurityException
Indicates the time that the IFSJavaFile was last modified.- Overrides:
lastModified
in classjava.io.File
- Returns:
- The time (measured in milliseconds since
01/01/1970 00:00:00 GMT) that the IFSJavaFile was
last modified, or
0
if it does not exist. - Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
length
public long length() throws java.lang.SecurityException
Indicates the length of this IFSJavaFile.- Overrides:
length
in classjava.io.File
- Returns:
- The length, in bytes, of the IFSJavaFile,
or
0
((IFSJavaFile) if it does not exist. - Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
list
public java.lang.String[] list() throws java.lang.SecurityException
Lists the files in this IFSJavaFile directory.- Overrides:
list
in classjava.io.File
- Returns:
- An array of object names in the directory. This list does not include the current directory or the parent directory. If this IFSJavaFile is not a directory, null is returned. If this IFSJavaFile is an empty directory, an empty string array is returned.
- Throws:
java.lang.SecurityException
- If the user is denied access to the file.- See Also:
listFiles()
-
list
public java.lang.String[] list(java.io.FilenameFilter filter) throws java.lang.SecurityException
Lists the files in this IFSJavaFile directory that satisfy filter.- Overrides:
list
in classjava.io.File
- Parameters:
filter
- The file name filter.- Returns:
- An array of object names in the directory that satisfy
the file name filter. This list does not include the current
directory or the parent directory. If this IFSJavaFile is not
a directory, null is returned. If this IFSJavaFile is an empty
directory, or the file name filter does
not match any files, an empty string array is returned.
The IFSJavaFile object passed to the file name filter object have cached
file attribute information. Maintaining references to these
IFSJavaFile objects after the list operation increases the
chances that their file attribute information will not be valid.
The following example demonstrates the use of this method:
class AcceptClass implements java.io.FilenameFilter { public boolean accept(java.io.File dir, java.lang.String name) { if (name.startsWith("IFS")) return true; return false; } }
IFSJavaFile file = new IFSJavaFile(new AS400("enterprise"), path); AcceptClass ac = new AcceptClass(); file.list(ac); - Throws:
java.lang.SecurityException
- If the user is denied access to the file.- See Also:
listFiles(FilenameFilter)
-
list
public java.lang.String[] list(IFSFileFilter filter) throws java.lang.SecurityException
Lists the files in the IFSJavaFile directory that satisfy file name filter.- Parameters:
filter
- The file name filter.- Returns:
- An array of object names in the directory that
satisfy the file name filter. This list does not include the current
directory or the parent directory.
If this IFSJavaFile is not a directory, null is
returned. If this IFSJavaFile is an empty directory, or
the file name filter does not match any files, an empty string array
is returned. The IFSFile object passed to the file name filter object
have cached file attribute information. Maintaining
references to these IFSFile objects after the list operation
increases the chances that their file attribute information
will not be valid.
The following example demonstrates the use of this method:
class AcceptClass implements IFSFileFilter { public boolean accept(IFSFile file) { if (file.getName().startsWith("IFS")) return true; return false; } }
IFSJavaFile file = new IFSJavaFile(new AS400("enterprise"), path); AcceptClass ac = new AcceptClass(); file.list(ac); - Throws:
java.lang.SecurityException
- If the user is denied access to the file.- See Also:
listFiles(IFSFileFilter)
-
list
public java.lang.String[] list(IFSFileFilter filter, java.lang.String pattern) throws java.lang.SecurityException
Lists the files in this IFSJavaFile directory that satisfy filter and pattern.Note:
If the file does not match pattern, it will not be processed by filter.- Parameters:
filter
- The file name filter.pattern
- The pattern that all filenames must match. Acceptable characters are wildcards (* - matches multiple characters) and question marks (? - matches one character). Pattern must not be null.- Returns:
- An array of object names in the directory that satisfy the file name filter and pattern. This list does not include the current directory or the parent directory. If this IFSJavaFile is not a directory, null is returned. If this IFSJavaFile is an empty directory, or the file name filter or pattern does not match any files, an empty string array is returned. The IFSFile object passed to the file name filter object have cached file attribute information. Maintaining references to these IFSFile objects after the list operation increases the chances that their file attribute information will not be valid.
- Throws:
java.lang.SecurityException
- If the user is denied access to the file.- See Also:
listFiles(IFSFileFilter,String)
-
list
public java.lang.String[] list(java.lang.String pattern) throws java.lang.SecurityException
Lists the files in this IFSJavaFile directory that match pattern.- Parameters:
pattern
- The pattern that all filenames must match. Acceptable characters are wildcards (* - matches multiple characters) and question marks (? - matches one character).- Returns:
- An array of object names in the directory that match the pattern. This list does not include the current directory or the parent directory. If this IFSJavaFile is not a directory, null is returned. If this IFSJavaFile is an empty directory, or the pattern does not match any files, an empty string array is returned.
- Throws:
java.lang.SecurityException
- If the user is denied access to the file.- See Also:
listFiles(String)
-
listFiles
public java.io.File[] listFiles() throws java.lang.SecurityException
Lists the files in this IFSJavaFile directory. With the use of this function, attribute information is cached and will not be refreshed from the IBM i system. This means attribute information may become inconsistent with the IBM i system.- Overrides:
listFiles
in classjava.io.File
- Returns:
- An array of objects in the directory. This list does not include the current directory or the parent directory. If this IFSJavaFile is not a directory, null is returned. If this IFSJavaFile is an empty directory, an empty object array is returned.
- Throws:
java.lang.SecurityException
- If the user is denied access to the file.- See Also:
list()
-
listFiles
public java.io.File[] listFiles(java.io.FilenameFilter filter) throws java.lang.SecurityException
Lists the files in this IFSJavaFile directory that satisfy filter. With the use of this function, attribute information is cached and will not be refreshed from the IBM i system. This means attribute information may become inconsistent with the IBM i system.- Overrides:
listFiles
in classjava.io.File
- Parameters:
filter
- The file name filter.- Returns:
- An array of objects in the directory that satisfy
the file name filter. This list does not include the current
directory or the parent directory. If this IFSJavaFile is not
a directory, null is returned. If this IFSJavaFile is an empty
directory, or the file name filter does
not match any files, an empty object array is returned.
The IFSJavaFile object passed to the file name filter object has cached
file attribute information. Maintaining references to these
IFSJavaFile objects after the list operation increases the
chances that their file attribute information will not be valid.
The following example demonstrates the use of this method:
class AcceptClass implements java.io.FilenameFilter { public boolean accept(java.io.File dir, java.lang.String name) { if (name.startsWith("IFS")) return true; return false; } }
IFSJavaFile file = new IFSJavaFile(new AS400("enterprise"), path); AcceptClass ac = new AcceptClass(); file.listFiles(ac); - Throws:
java.lang.SecurityException
- If the user is denied access to the file.- See Also:
list(FilenameFilter)
-
listFiles
public java.io.File[] listFiles(java.io.FileFilter filter) throws java.lang.SecurityException
Lists the files in this IFSJavaFile directory that satisfy filter. With the use of this function, attribute information is cached and will not be refreshed from the IBM i system. This means attribute information may become inconsistent with the IBM i system.- Overrides:
listFiles
in classjava.io.File
- Parameters:
filter
- The file filter.- Returns:
- An array of objects in the directory that satisfy
the file filter. This list does not include the current
directory or the parent directory. If this IFSJavaFile is not
a directory, null is returned. If this IFSJavaFile is an empty
directory, or the file filter does
not match any files, an empty object array is returned.
The IFSJavaFile object passed to the file filter object has cached
file attribute information. Maintaining references to these
IFSJavaFile objects after the list operation increases the
chances that their file attribute information will not be valid.
The following example demonstrates the use of this method:
class AcceptClass implements java.io.FileFilter { public boolean accept(java.io.File file) { if (file.getName().startsWith("IFS")) return true; return false; } }
IFSJavaFile file = new IFSJavaFile(new AS400("enterprise"), path); AcceptClass ac = new AcceptClass(); file.listFiles(ac); - Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
listFiles
public java.io.File[] listFiles(IFSFileFilter filter) throws java.lang.SecurityException
Lists the files in the IFSJavaFile directory that satisfy file name filter. With the use of this function, attribute information is cached and will not be refreshed from the IBM i system. This means attribute information may become inconsistent with the IBM i system.- Parameters:
filter
- The file name filter.- Returns:
- An array of objects in the directory that
satisfy the file name filter. This list does not include the current
directory or the parent directory.
If this IFSJavaFile is not a directory, null is
returned. If this IFSJavaFile is an empty directory, or
the file name filter does not match any files, an empty object array
is returned. The IFSFile object passed to the file name filter object
has cached file attribute information. Maintaining
references to these IFSFile objects after the list operation
increases the chances that their file attribute information
will not be valid.
The following example demonstrates the use of this method:
class AcceptClass implements IFSFileFilter { public boolean accept(IFSFile file) { if (file.getName().startsWith("IFS")) return true; return false; } }
IFSJavaFile file = new IFSJavaFile(new AS400("enterprise"), path); AcceptClass ac = new AcceptClass(); file.listFiles(ac); - Throws:
java.lang.SecurityException
- If the user is denied access to the file.- See Also:
list(IFSFileFilter)
-
listFiles
public java.io.File[] listFiles(IFSFileFilter filter, java.lang.String pattern) throws java.lang.SecurityException
Lists the files in this IFSJavaFile directory that satisfy filter and pattern. With the use of this function, attribute information is cached and will not be refreshed from the IBM i system. This means attribute information may become inconsistent with the IBM i system.Note:
If the file does not match pattern, it will not be processed by filter.- Parameters:
filter
- The file name filter.pattern
- The pattern that all filenames must match. Acceptable characters are wildcards (* - matches multiple characters) and question marks (? - matches one character). Pattern must not be null.- Returns:
- An array of objects in the directory that satisfy the file name filter and pattern. This list does not include the current directory or the parent directory. If this IFSJavaFile is not a directory, null is returned. If this IFSJavaFile is an empty directory, or the file name filter or pattern does not match any files, an empty object array is returned. The IFSFile object passed to the file name filter object has cached file attribute information. Maintaining references to these IFSFile objects after the list operation increases the chances that their file attribute information will not be valid.
- Throws:
java.lang.SecurityException
- If the user is denied access to the file.- See Also:
list(IFSFileFilter,String)
-
listFiles
public java.io.File[] listFiles(java.lang.String pattern) throws java.lang.SecurityException
Lists the files in this IFSJavaFile directory that match pattern. With the use of this function, attribute information is cached and will not be refreshed from the IBM i system. This means attribute information may become inconsistent with the IBM i system.- Parameters:
pattern
- The pattern that all filenames must match. Acceptable characters are wildcards (* - matches multiple characters) and question marks (? - matches one character).- Returns:
- An array of object names in the directory that match the pattern. This list does not include the current directory or the parent directory. If this IFSJavaFile is not a directory, null is returned. If this IFSJavaFile is an empty directory, or the pattern does not match any files, an empty string array is returned.
- Throws:
java.lang.SecurityException
- If the user is denied access to the file.- See Also:
list(String)
-
listRoots
public static java.io.File[] listRoots()
Lists the file system roots for the integrated file system of the IBM i system. The IBM i integrated file system has only one root -- "/".- Returns:
- An array of IFSJavaFile objects that represent the file system roots of the integrated file system of the IBM i system. Since the IBM i integrated file system has only one root, the returned array contains only one element.
-
mkdir
public boolean mkdir() throws java.lang.SecurityException
Creates a directory whose path name is specified by this IFSJavaFile.- Overrides:
mkdir
in classjava.io.File
- Returns:
true
if the directory could be created;false
otherwise.- Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
mkdirs
public boolean mkdirs() throws java.lang.SecurityException
Creates a directory whose path name is specified by this IFSJavaFile, including any necessary parent directories.- Overrides:
mkdirs
in classjava.io.File
- Returns:
true
if the directory (or directories) could be created;false
otherwise.- Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
renameTo
public boolean renameTo(IFSJavaFile dest) throws java.lang.SecurityException
Renames the IFSJavaFile to have the path name of dest. Wildcards are not permitted in this file name.- Parameters:
dest
- The new filename.- Returns:
true
if the renaming succeeds;false
otherwise.- Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
renameTo
public boolean renameTo(java.io.File dest) throws java.lang.SecurityException
Renames the IFSJavaFile to have the path name of dest. Wildcards are not permitted in this file name.- Overrides:
renameTo
in classjava.io.File
- Parameters:
dest
- An object specifying the new filename. If this object is not an IFSJavaFile, the rename will fail.- Returns:
true
if the renaming succeeds;false
otherwise.- Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
setLastModified
public boolean setLastModified(long time) throws java.lang.SecurityException
Sets the last modified time of the file named by this IFSJavaFile object.- Overrides:
setLastModified
in classjava.io.File
- Parameters:
time
- The new last modified time, measured in milliseconds since 00:00:00 GMT, January 1, 1970. If -1, sets the last modified time to the current system time.- Returns:
true
if the time is set;false
otherwise.- Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
setLength
public boolean setLength(int length) throws java.lang.SecurityException
Sets the length of the file named by this IFSJavaFile object. The file can be made larger or smaller. If the file is made larger, the contents of the new bytes of the file are undetermined.- Parameters:
length
- The new length, in bytes.- Returns:
- true if successful; false otherwise.
- Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
setPath
public boolean setPath(java.lang.String path)
Sets the path for this IFSJavaFile.- Parameters:
path
- The absolute file path.- Returns:
true
if the path was set;false
otherwise.
-
setPatternMatching
public void setPatternMatching(int patternMatching) throws java.io.IOException
Sets the pattern-matching behavior used when files are listed by any of the list() or listFiles() methods. The default is PATTERN_POSIX.- Parameters:
patternMatching
- EitherPATTERN_POSIX
,PATTERN_POSIX_ALL
, orPATTERN_OS2
- Throws:
java.io.IOException
- If an error occurs while communicating with the system.ConnectionDroppedException
- If the connection is dropped unexpectedly.ExtendedIOException
- If an error occurs while communicating with the system.ServerStartupException
- If the host server cannot be started.
-
setReadOnly
public boolean setReadOnly() throws java.lang.SecurityException
Marks the file named by this IFSJavaFile object so that only read operations are allowed. On the IBM i system, a file is marked read only by setting the read only attribute of the file.- Overrides:
setReadOnly
in classjava.io.File
- Returns:
true
if the read only attribute is set;false
otherwise.- Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
setSystem
public boolean setSystem(AS400 system)
Sets the system.- Parameters:
system
- The system object.- Returns:
true
if the system was set;false
otherwise.
-
setExecutable
public boolean setExecutable(boolean executable) throws java.lang.SecurityException
A convenience method to set the owner's execute permission for this abstract pathname. This method is supported for IBM i V5R1 and higher. For older releases, it simply returns false.An invocation of this method of the form file.setExcutable(arg) behaves in exactly the same way as the invocation file.setExecutable(arg, true)
- Overrides:
setExecutable
in classjava.io.File
- Parameters:
executable
- If true, sets the access permission to allow execute operations; if false, to disallow execute operations.- Returns:
- true if and only if the operation succeeded. The operation will fail if the user does not have permission to change the access permissions of this abstract pathname.
- Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
setExecutable
public boolean setExecutable(boolean executable, boolean ownerOnly) throws java.lang.SecurityException
Sets the owner's or everybody's execute permission for this abstract pathname. This method is supported for IBM i V5R1 and higher. For older releases, it simply returns false.- Overrides:
setExecutable
in classjava.io.File
- Parameters:
executable
- If true, sets the access permission to allow execute operations; if false, to disallow execute operations.ownerOnly
- If true, the execute permission applies only to the owner's execute permission; otherwise, it applies to everybody.- Returns:
- true if and only if the operation succeeded. The operation will fail if the user does not have permission to change the access permissions of this abstract pathname.
- Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
setReadable
public boolean setReadable(boolean readable) throws java.lang.SecurityException
A convenience method to set the owner's read permission for this abstract pathname. This method is supported for IBM i V5R1 and higher. For older releases, it simply returns false.An invocation of this method of the form file.setReadable(arg) behaves in exactly the same way as the invocation file.setReadable(arg, true)
- Overrides:
setReadable
in classjava.io.File
- Parameters:
readable
- If true, sets the access permission to allow read operations; if false, to disallow read operations.- Returns:
- true if and only if the operation succeeded. The operation will fail if the user does not have permission to change the access permissions of this abstract pathname.
- Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
setReadable
public boolean setReadable(boolean readable, boolean ownerOnly) throws java.lang.SecurityException
Sets the owner's or everybody's read permission for this abstract pathname. This method is supported for IBM i V5R1 and higher. For older releases, it simply returns false.- Overrides:
setReadable
in classjava.io.File
- Parameters:
readable
- If true, sets the access permission to allow read operations; if false, to disallow read operations.ownerOnly
- If true, the read permission applies only to the owner's read permission; otherwise, it applies to everybody.- Returns:
- true if and only if the operation succeeded. The operation will fail if the user does not have permission to change the access permissions of this abstract pathname.
- Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
setWritable
public boolean setWritable(boolean writable) throws java.lang.SecurityException
A convenience method to set the owner's write permission for this abstract pathname. This method is supported for IBM i V5R1 and higher. For older releases, it simply returns false.An invocation of this method of the form file.setWritable(arg) behaves in exactly the same way as the invocation file.setWritable(arg, true)
- Overrides:
setWritable
in classjava.io.File
- Parameters:
writable
- If true, sets the access permission to allow write operations; if false to disallow write operations- Returns:
- true if and only if the operation succeeded. The operation will fail if the user does not have permission to change the access permissions of this abstract pathname.
- Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
setWritable
public boolean setWritable(boolean writable, boolean ownerOnly) throws java.lang.SecurityException
Sets the owner's or everybody's write permission for this abstract pathname. This method is supported for IBM i V5R1 and higher. For older releases, it simply returns false.- Overrides:
setWritable
in classjava.io.File
- Parameters:
writable
- If true, sets the access permission to allow write operations; if false, to disallow write operations.ownerOnly
- If true, the write permission applies only to the owner's write permission; otherwise, it applies to everybody.- Returns:
- true if and only if the operation succeeded. The operation will fail if the user does not have permission to change the access permissions of this abstract pathname.
- Throws:
java.lang.SecurityException
- If the user is denied access to the file.
-
toString
public java.lang.String toString()
Returns a string representation of this object.- Overrides:
toString
in classjava.io.File
- Returns:
- A string giving the path name of this object.
-
toURL
public java.net.URL toURL() throws java.net.MalformedURLException
Converts the abstract path name into afile:
URL. The IBM i file/directory will be accessed and if it is a directory the resulting URL will end with the IBM i separator character (forward slash). The system name will be obtained from the AS400 object. If the path name or AS400 object has not been set, a NullPointerException will be thrown.- Overrides:
toURL
in classjava.io.File
- Returns:
- The URL form of the abstract path name of this object.
- Throws:
java.net.MalformedURLException
- If the URL cannot be formed.
-
-