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

97 lines
5.3 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="FTP class" />
<meta name="abstract" content="The FTP class provides a programmable interface to FTP functions." />
<meta name="description" content="The FTP class provides a programmable interface to FTP functions." />
<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="ftp" />
<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>FTP class</title>
</head>
<body id="ftp"><a name="ftp"><!-- --></a>
<!-- Java sync-link --><script language="Javascript" src="../rzahg/synch.js" type="text/javascript"></script>
<h1 class="topictitle1">FTP class</h1>
<div><p>The FTP class provides a programmable interface to FTP functions. </p>
<div class="section"><p><a href="javadoc/com/ibm/as400/access/FTP.html">FTP class</a> </p>
<p>You are no longer required to use java.runtime.exec()
or tell your users to run FTP commands in a separate application. That is,
you can program FTP functions directly into your application. So, from within
your program, you can do the following: </p>
<ul><li><a href="javadoc/com/ibm/as400/access/FTP.html#CONNECT()"> Connect</a> to an FTP server</li>
<li><a href="javadoc/com/ibm/as400/access/FTP.html#ISSUECOMMAND(JAVA.LANG.STRING)"> Send</a> commands to the server</li>
<li><a href="javadoc/com/ibm/as400/access/FTP.html#LS()">List</a> the
files in a directory</li>
<li><a href="javadoc/com/ibm/as400/access/FTP.html#GET(JAVA.LANG.STRING)"> Get</a> files from the server <strong>and</strong></li>
<li><a href="javadoc/com/ibm/as400/access/FTP.html#PUT(JAVA.IO.FILE, JAVA.LANG.STRING)"> Put</a> files to the server</li>
</ul>
<p id="ftp__class"><a name="ftp__class"><!-- --></a><strong>Example: Using FTP to copy files from a server</strong></p>
<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>For example, with the FTP class, you
can <a href="javadoc/com/ibm/as400/access/FTP.html#EXAMPLE">copy</a> a set of files from a directory on a server:</p>
<pre> FTP client = new FTP("myServer", "myUID", "myPWD");
client.cd("/myDir");
client.setDataTransferType(FTP.BINARY);
String [] entries = client.ls();
for (int i = 0; i &lt; entries.length; i++)
{
System.out.println("Copying " + entries[i]);
try
{
client.get(entries[i], "c:\\ftptest\\" + entries[i]);
}
catch (Exception e)
{
System.out.println(" copy failed, likely this is a directory");
}
}
client.disconnect();</pre>
<p>FTP is a generic interface that works
with many different FTP servers. Therefore, it is up to the programmer to
match the semantics of the server.</p>
</div>
<div class="section"><h4 class="sectiontitle">AS400FTP subclass</h4><p>While the FTP class is a generic
FTP interface, the <a href="javadoc/com/ibm/as400/access/AS400FTP.html">AS400FTP subclass</a> is written specifically for the FTP
server on the server. That is, it understands the semantics of the FTP server
on the iSeries™ server.
For example, this class understands the various steps needed to transfer a
save file to the server and performs these steps automatically. AS400FTP also
ties into the security facilities of the IBM<sup>®</sup> Toolbox for Java™. As with other IBM Toolbox for Java classes, AS400FTP depends on the AS400
object for system name, user ID, and password. </p>
<p id="ftp__subclass"><a name="ftp__subclass"><!-- --></a><strong>Example:
Using AS400FTP to save a file to the server</strong></p>
<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 puts a save file to the server. Note the application does not set
data transfer type to binary or use CommandCall to create the save file. Since
the extension is .savf, AS400FTP class detects the file to put is a save file
so it does these steps automatically.</p>
<pre> AS400 system = new AS400();
AS400FTP ftp = new AS400FTP(system);
ftp.put("myData.savf", "/QSYS.LIB/MYLIB.LIB/MYDATA.SAVF");
</pre>
</div>
</div>
</body>
</html>