105 lines
5.1 KiB
HTML
105 lines
5.1 KiB
HTML
|
<?xml version="1.0" encoding="UTF-8"?>
|
||
|
<!DOCTYPE html
|
||
|
PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
|
||
|
<html lang="en-us" xml:lang="en-us">
|
||
|
<head>
|
||
|
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
|
||
|
<meta name="security" content="public" />
|
||
|
<meta name="Robots" content="index,follow" />
|
||
|
<meta http-equiv="PICS-Label" content='(PICS-1.1 "http://www.icra.org/ratingsv02.html" l gen true r (cz 1 lz 1 nz 1 oz 1 vz 1) "http://www.rsac.org/ratingsv01.html" l gen true r (n 0 s 0 v 0 l 0) "http://www.classify.org/safesurf/" l gen true r (SS~~000 1))' />
|
||
|
<meta name="DC.Type" content="reference" />
|
||
|
<meta name="DC.Title" content="IFSJavaFile class" />
|
||
|
<meta name="abstract" content="This class represents a file in the iSeries integrated file system and extends the java.io.File class. IFSJavaFile allows you to write files for the java.io.File interface that access iSeries integrated file systems." />
|
||
|
<meta name="description" content="This class represents a file in the iSeries integrated file system and extends the java.io.File class. IFSJavaFile allows you to write files for the java.io.File interface that access iSeries integrated file systems." />
|
||
|
<meta name="copyright" content="(C) Copyright IBM Corporation 2006" />
|
||
|
<meta name="DC.Rights.Owner" content="(C) Copyright IBM Corporation 2006" />
|
||
|
<meta name="DC.Format" content="XHTML" />
|
||
|
<meta name="DC.Identifier" content="ifsjava" />
|
||
|
<meta name="DC.Language" content="en-us" />
|
||
|
<!-- All rights reserved. Licensed Materials Property of IBM -->
|
||
|
<!-- US Government Users Restricted Rights -->
|
||
|
<!-- Use, duplication or disclosure restricted by -->
|
||
|
<!-- GSA ADP Schedule Contract with IBM Corp. -->
|
||
|
<link rel="stylesheet" type="text/css" href="./ibmdita.css" />
|
||
|
<link rel="stylesheet" type="text/css" href="./ic.css" />
|
||
|
<title>IFSJavaFile class</title>
|
||
|
</head>
|
||
|
<body id="ifsjava"><a name="ifsjava"><!-- --></a>
|
||
|
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
|
||
|
<h1 class="topictitle1">IFSJavaFile class</h1>
|
||
|
<div><p>This class represents a file in the iSeries™ integrated file system and extends
|
||
|
the java.io.File class. IFSJavaFile allows you to write files for the java.io.File
|
||
|
interface that access iSeries integrated file systems.</p>
|
||
|
<div class="section"><p><a href="javadoc/com/ibm/as400/access/IFSJavaFile.html#NAVBAR_TOP"> IFSJavaFile</a> </p>
|
||
|
<p>IFSJavaFile makes portable interfaces
|
||
|
that are compatible with java.io.File and uses only the errors and exceptions
|
||
|
that java.io.File uses. IFSJavaFile uses the security manager features from
|
||
|
java.io.File, but unlike java.io.File, IFSJavaFile uses security features
|
||
|
continuously.</p>
|
||
|
<p>You use IFSJavaFile with IFSFileInputStream and IFSFileOutputStream.
|
||
|
It does not support java.io.FileInputStream and java.io.FileOutputStream.</p>
|
||
|
<p>IFSJavaFile
|
||
|
is based on IFSFile; however, its interface is more like java.io.File than
|
||
|
IFSFile. IFSFile is an alternative to the IFSJavaFile class.</p>
|
||
|
<p>You can
|
||
|
get the list of files in a directory by using either the list() method or
|
||
|
the listFiles() method:</p>
|
||
|
<ul><li>The listFiles() method performs better because it retrieves and caches
|
||
|
information for each file on the initial call. After that, information on
|
||
|
each file is retrieved from the cache.</li>
|
||
|
<li>The list() method retrieves information on each file in a separate request,
|
||
|
making it slower and more demanding of server resources.</li>
|
||
|
</ul>
|
||
|
<div class="note"><span class="notetitle">Note:</span> Using listFiles() means that the information in the cache eventually
|
||
|
become stale, so you may need to refresh the data.</div>
|
||
|
</div>
|
||
|
<div class="section" id="ifsjava__ifsjex"><a name="ifsjava__ifsjex"><!-- --></a><h4 class="sectiontitle">Example: Using IFSJavaFile</h4><div class="note"><span class="notetitle">Note:</span> Read
|
||
|
the <a href="codedisclaimer.htm#codedisclaimer">Code example disclaimer</a> for
|
||
|
important legal information.</div>
|
||
|
<p>The following example shows how to use
|
||
|
the IFSJavaFile class:</p>
|
||
|
<pre> // Work with /Dir/File.txt on the system flash.
|
||
|
AS400 as400 = new AS400("flash");
|
||
|
IFSJavaFile file = new IFSJavaFile(as400, "/Dir/File.txt");
|
||
|
|
||
|
// Determine the parent directory of the file.
|
||
|
String directory = file.getParent();
|
||
|
|
||
|
// Determine the name of the file.
|
||
|
String name = file.getName();
|
||
|
|
||
|
// Determine the file size.
|
||
|
long length = file.length();
|
||
|
|
||
|
// Determine when the file was last modified.
|
||
|
Date date = new Date(file.lastModified());
|
||
|
|
||
|
// Delete the file.
|
||
|
if (file.delete() == false)
|
||
|
{
|
||
|
// Display the error code.
|
||
|
System.err.println("Unable to delete file.");
|
||
|
}
|
||
|
|
||
|
try
|
||
|
{
|
||
|
IFSFileOutputStream os =
|
||
|
new IFSFileOutputStream(file.getSystem(), file, IFSFileOutputStream.SHARE_ALL, false);
|
||
|
byte[] data = new byte[256];
|
||
|
int i = 0;
|
||
|
for (; i < data.length; i++)
|
||
|
{
|
||
|
data[i] = (byte) i;
|
||
|
os.write(data[i]);
|
||
|
}
|
||
|
os.close();
|
||
|
}
|
||
|
catch (Exception e)
|
||
|
{
|
||
|
System.err.println ("Exception: " + e.getMessage());
|
||
|
}</pre>
|
||
|
</div>
|
||
|
</div>
|
||
|
|
||
|
</body>
|
||
|
</html>
|