ibm-information-center/dist/eclipse/plugins/i5OS.ic.rzahh_5.4.0.1/ifsfis.htm

87 lines
4.8 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="IFSFileInputStream" />
<meta name="abstract" content="The IFSFileInputStream class represents an input stream for reading data from a file on the server." />
<meta name="description" content="The IFSFileInputStream class represents an input stream for reading data from a file on the server." />
<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="ifsfis" />
<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>IFSFileInputStream</title>
</head>
<body id="ifsfis"><a name="ifsfis"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">IFSFileInputStream</h1>
<div><p>The IFSFileInputStream class represents an input stream for reading
data from a file on the server. </p>
<div class="section"><p><a href="javadoc/com/ibm/as400/access/IFSFileInputStream.html#NAVBAR_TOP"> IFSFileInputStream</a></p>
<p>As in the IFSFile class, methods
exist in IFSFileInputStream that duplicate the methods in FileInputStream
from the java.io package. In addition to these methods, IFSFileInputStream
has additional methods specific to iSeries™ servers. The IFSFileInputStream
class allows a Java™ program to do the following:</p>
<ul><li><a href="javadoc/com/ibm/as400/access/IFSFileInputStream.html#CONSTRUCTOR_DETAIL"> Open</a> a file for reading. The file must exist since this
class does not create files on the server. You can use a constructor that
allows you to specify the file sharing mode.</li>
<li>Determine the <a href="javadoc/com/ibm/as400/access/IFSFileInputStream.html#AVAILABLE()"> number of bytes</a> in the stream.</li>
<li><a href="javadoc/com/ibm/as400/access/IFSFileInputStream.html#READ()"> Read</a> bytes from the stream.</li>
<li><a href="javadoc/com/ibm/as400/access/IFSFileInputStream.html#SKIP(LONG)"> Skip</a> bytes in the stream.</li>
<li><a href="javadoc/com/ibm/as400/access/IFSFileInputStream.html#LOCK(INT)"> Lock</a> or <a href="javadoc/com/ibm/as400/access/IFSFileInputStream.html#UNLOCK(COM.IBM.AS400.ACCESS.IFSKEY)"> unlock</a> bytes in the stream.</li>
<li><a href="javadoc/com/ibm/as400/access/IFSFileInputStream.html#CLOSE()"> Close</a> the file.</li>
</ul>
<p>As in FileInputStream in java.io, this class allows a Java program
to read a stream of bytes from the file. The Java program reads the bytes sequentially
with only the additional option of skipping bytes in the stream.</p>
<p>In
addition to the methods in FileInputStream, IFSFileInputStream gives the Java program
the following options:</p>
<ul><li>Locking and unlocking bytes in the stream. See <a href="ifskey.htm#ifskey">IFSKey</a> for
more information.</li>
<li>Specifying a sharing mode when the file is opened. See <a href="ifsmode.htm#ifsmode">sharing
modes</a> for more information.</li>
</ul>
</div>
<div class="section"><h4 class="sectiontitle">Example: Using IFSFileInputStream</h4><p>The following
example shows how to use the IFSFileInputStream class.</p>
<pre> // Create an AS400 object.
AS400 sys = new AS400("mySystem.myCompany.com");
// Open a file object that
// represents the file.
IFSFileInputStream aFile = new IFSFileInputStream(sys,"/mydir1/mydir2/myfile");
// Determine the number of bytes in
// the file.
int available = aFile.available();
// Allocate a buffer to hold the data
byte[] data = new byte[10240];
// Read the entire file 10K at a time
for (int i = 0; i &lt; available; i += 10240)
{
aFile.read(data);
}
// Close the file.
aFile.close();</pre>
</div>
</div>
</body>
</html>