|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Object
|
+--java.io.File
|
+--com.ibm.as400.access.IFSJavaFile
The IFSJavaFile class represents a file in the
integrated file system of the iSeries server.
IFSJavaFile extends the java.io.File class and allows programs
to be written for the java.io.File interface and still access
the iSeries integrated file system.
IFSFile should be considered as an alternate to java.io.File class.
When should IFSJavaFile be used?
Notes:
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 iSeries or the local client.
int location = ON_THE_AS400;
java.io.File file = null;
java.io.OutputStream os = null;
if (location == ON_THE_AS400)
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_AS400)
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);
}
IFSFile,
IFSFileInputStream,
IFSFileOutputStream, Serialized Form| Fields inherited from class java.io.File |
pathSeparator, pathSeparatorChar, separator, separatorChar |
| Constructor Summary | |
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(IFSJavaFile directory,
java.lang.String name)
Creates a new IFSJavaFile instance from a parent abstract pathname and a child pathname string. |
|
| Method Summary | |
boolean |
canRead()
Indicates if the program can read from the IFSJavaFile. |
boolean |
canWrite()
Indicates if the program can write to the IFSJavaFile. |
int |
compareTo(java.io.File file)
Compares the path of IFSJavaFile with a File's path. |
int |
compareTo(IFSFile file)
Compares the path of IFSJavaFile with a IFSFile's path. |
int |
compareTo(IFSJavaFile file)
Compares the paths of two IFSJavaFiles. |
int |
compareTo(java.lang.Object obj)
Compares the path of IFSJavaFile with an Object's path. |
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. |
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. |
AS400 |
getSystem()
Returns the system that this object references. |
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. A file is "normal" if it is not a directory or a container of other objects. |
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 iSeries server. |
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 |
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. |
boolean |
setReadOnly()
Marks the file named by this IFSJavaFile object so that only read operations are allowed. |
boolean |
setSystem(AS400 system)
Sets the system. |
java.lang.String |
toString()
Returns a string representation of this object. |
java.net.URL |
toURL()
Converts the abstract path name into a file: URL. |
| Methods inherited from class java.io.File |
createTempFile, createTempFile, deleteOnExit |
| Methods inherited from class java.lang.Object |
clone, finalize, getClass, notify, notifyAll, wait, wait, wait |
| Constructor Detail |
public IFSJavaFile()
public IFSJavaFile(AS400 system,
java.lang.String path)
system - The AS400 that contains the IFSJavaFile.path - The file path name where the IFSJavaFile is or will be stored.
public IFSJavaFile(AS400 system,
java.lang.String path,
java.lang.String name)
system - The AS400 that contains the IFSJavaFile.path - The file path name where the IFSJavaFile is or will be stored.name - The name of the IFSJavaFile object.
public IFSJavaFile(IFSJavaFile directory,
java.lang.String name)
The directory argument cannot be null. The constructed
IFSJavaFile instance uses the following settings taken from
directory:
directory - The directory where the IFSJavaFile is or will be stored.name - The name of the IFSJavaFile object.
public IFSJavaFile(AS400 system,
IFSJavaFile directory,
java.lang.String name)
system - The AS400 that contains the IFSJavaFile.directory - The directory where the IFSJavaFile is or will be stored.name - The name of the IFSJavaFile object.| Method Detail |
public boolean canRead()
canRead in class java.io.Filetrue if the object exists and is readable; false otherwise.public boolean canWrite()
canWrite in class java.io.Filetrue if the object exists and is writeable; false otherwise.public int compareTo(IFSJavaFile file)
The following examples demonstrate the use of this method:
In this example, returnCode would be less than 0 because the
path of file is less than the path of file2.
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 of file is greater than the path of file2.
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 of file is less than the path of file2.
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.
file - The IFSJavaFile to be compared.0 if this IFSJavaFile path equals file's path;
a value less than 0 if this IFSJavaFile path is less than the file's
path; and a value greater than 0 if this IFSJavaFile path is greater
than the file's path.public int compareTo(java.io.File file)
File's path.
Note:
The comparison is case sensitive.
compareTo in class java.io.Filefile - The File to be compared.0 if this IFSJavaFile path equals the argument's path;
a value less than 0 if this IFSJavaFile path is less than the argument's
path; and a value greater than 0 if this IFSJavaFile path is greater
than the argument's path.public int compareTo(IFSFile file)
IFSFile's path.
Note:
The comparison is case sensitive.
file - The IFSFile to be compared.0 if this IFSJavaFile path equals the argument's path;
a value less than 0 if this IFSJavaFile path is less than the argument's
path; and a value greater than 0 if this IFSJavaFile path is greater
than the argument's path.public int compareTo(java.lang.Object obj)
Object's path.
If the other object is an IFSJavaFile,
then this function behaves like compareTo(IFSJavaFile).
If the other object is an IFSFile,
then this function behaves like compareTo(IFSFile).
If the other object is a java.io.File,
then this function behaves like compareTo(File).
Otherwise, it throws a ClassCastException, since
IFSJavaFile is comparable only to IFSJavaFile, IFSFile, and File.
Note:
The comparison is case sensitive.
compareTo in class java.io.Fileobj - The Object to be compared.0 if this IFSJavaFile path equals the argument's path;
a value less than 0 if this IFSJavaFile path is less than the argument's
path; and a value greater than 0 if this IFSJavaFile path is greater
than the argument's path.
public boolean createNewFile()
throws java.io.IOException
createNewFile in class java.io.Filejava.io.IOException - If an I/O error occurs while communicating with the iSeries server.public boolean delete()
delete in class java.io.Filetrue if the file is successfully deleted;
false otherwise.public boolean equals(java.lang.Object obj)
true if and only if the argument is
not null and is a IFSJavaFile
object whose path name is equal to the path name of
this IFSJavaFile,
and system names of the objects are equal.equals in class java.io.Fileobj - The object to compare with.true if the objects are the same;
false otherwise.public boolean exists()
exists in class java.io.Filetrue if the file specified by this object
exists; false otherwise.public java.io.File getAbsoluteFile()
getAbsoluteFile in class java.io.FilegetAbsolutePath()public java.lang.String getAbsolutePath()
getAbsolutePath in class java.io.FileisAbsolute()
public java.io.File getCanonicalFile()
throws java.io.IOException
getCanonicalFile in class java.io.Filejava.io.IOException - If an I/O error occurs while communicating with the iSeries server.getCanonicalPath()
public java.lang.String getCanonicalPath()
throws java.io.IOException
getCanonicalPath in class java.io.Filejava.io.IOException - If an I/O error occurs while communicating with the iSeries server.public java.lang.String getName()
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();
getName in class java.io.FileIFSJavaFile.public java.lang.String getParent()
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();
getParent in class java.io.Filenull otherwise.public java.io.File getParentFile()
getParentFile in class java.io.Filenull otherwise.getParent()public java.lang.String getPath()
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();
getPath in class java.io.Filepublic AS400 getSystem()
public int hashCode()
hashCode in class java.io.Filepublic boolean isAbsolute()
isAbsolute in class java.io.Filetrue if the path name specification is absolute; false otherwise.public boolean isDirectory()
isDirectory in class java.io.Filetrue if the IFSJavaFile exists and is a directory; false otherwise.public boolean isFile()
isFile in class java.io.Filetrue if the specified file exists and is a "normal" file; false otherwise.public boolean isHidden()
isHidden in class java.io.Filetrue if the file is hidden; false otherwise.public long lastModified()
lastModified in class java.io.File0 if it does not exist.public long length()
length in class java.io.File0 if it does not exist.public java.lang.String[] list()
list in class java.io.Filepublic java.lang.String[] list(java.io.FilenameFilter filter)
list in class java.io.Filefilter - The file name filter.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);
public java.lang.String[] list(IFSFileFilter filter)
filter - The file name filter.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);
public java.lang.String[] list(IFSFileFilter filter,
java.lang.String pattern)
Note:
If the file does not match pattern, it will not be processed by filter.
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.public java.lang.String[] list(java.lang.String pattern)
pattern - The pattern that all filenames must match.
Acceptable characters are wildcards (* - matches
multiple characters) and question marks (? - matches
one character).public java.io.File[] listFiles()
listFiles in class java.io.Filepublic java.io.File[] listFiles(java.io.FilenameFilter filter)
listFiles in class java.io.Filefilter - The file name filter.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);
public java.io.File[] listFiles(java.io.FileFilter filter)
listFiles in class java.io.Filefilter - The file filter.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);
public java.io.File[] listFiles(IFSFileFilter filter)
filter - The file name filter.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);
public java.io.File[] listFiles(IFSFileFilter filter,
java.lang.String pattern)
Note:
If the file does not match pattern, it will not be processed by filter.
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.public java.io.File[] listFiles(java.lang.String pattern)
pattern - The pattern that all filenames must match.
Acceptable characters are wildcards (* - matches
multiple characters) and question marks (? - matches
one character).public static java.io.File[] listRoots()
public boolean mkdir()
mkdir in class java.io.Filetrue if the directory could be created;
false otherwise.public boolean mkdirs()
mkdirs in class java.io.Filetrue if the directory (or directories) could be
created; false otherwise.public boolean renameTo(IFSJavaFile dest)
dest - The new filename.true if the renaming succeeds;
false otherwise.public boolean renameTo(java.io.File dest)
renameTo in class java.io.Filedest - An object specifying the new filename.
If this object is not an IFSJavaFile, the rename will fail.true if the renaming succeeds;
false otherwise.public boolean setLastModified(long time)
setLastModified in class java.io.Filetime - 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.true if the time is set; false otherwise.public boolean setLength(int length)
length - The new length, in bytes.public boolean setPath(java.lang.String path)
path - The absolute file path.true if the path was set;
false otherwise.public boolean setReadOnly()
setReadOnly in class java.io.Filetrue if the read only attribute is set; false otherwise.public boolean setSystem(AS400 system)
system - The iSeries system object.true if the system was set;
false otherwise.public java.lang.String toString()
toString in class java.io.File
public java.net.URL toURL()
throws java.net.MalformedURLException
file: URL.
The iSeries file/directory will be accessed and if it is a directory the
resulting URL will end with the iSeries separator character
(forward slash). The server name will be obtained from
the AS400 object. If the path name or AS400 object has
not been set, a NullPointerException will be thrown.toURL in class java.io.Filejava.net.MalformedURLException - If the URL cannot be formed.
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: INNER | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||