For example, with the FTP class, you can copy a set of files from a directory on a server:
FTP client = new FTP("myServer", "myUID", "myPWD"); client.cd("/myDir"); client.setDataTransferType(FTP.BINARY); String [] entries = client.ls(); for (int i = 0; i < 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();
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.
The following example puts a save file to
the server. 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");