AS/400 Toolbox for Java \
Access classes \ FTP class
FTP class
The
FTP class provides a programmable interface to FTP functions.
You no longer have 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:
-
Connect to an FTP server
-
Send commands to the server
- List the
files in a directory
- Get
files from the server and
- Put
files to the server
For example, with the FTP class, you can
copy a
set of files from a directory on a server.
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.
FTP subclass
While the FTP class
is a generic FTP interface, the AS400FTP subclass
is written specifically for the FTP server on the AS/400. That is,
it understands the semantics of the FTP server on the AS/400, so
the programmer doesn't have to. For example, this class understands
the various steps needed to transfer an AS/400 save file to the
AS/400 and performs these steps automatically. AS400FTP also ties
into the security facilities of the AS/400 Toolbox for Java. As
with other AS/400 Toolbox for Java classes, AS400FTP depends on the
AS400 object for system name, user ID, and password.
The following example puts a save file to the AS/400. Note the
application does not set data transfer type to binary or use
Toolbox 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.
AS400 system = new AS400();
AS400FTP ftp = new AS400FTP(system);
ftp.put("myData.savf", "/QSYS.LIB/MYLIB.LIB/MYDATA.SAVF");