|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.ibm.as400.access.FTP
com.ibm.as400.access.AS400FTP
public class AS400FTP
Represents a client for the IBM i FTP server. It is written to take advantage of IBM i features. Use the parent class, FTP, if you need a generic client.
AS400FTP does the following extra processing:
One restriction when the client is an IBM i system -- the userid and password must be set on the AS400 object in this environment. That is, *CURRENT will not work when connecting from one IBM i system to another IBM i system.
The extra processing includes internally using Toolbox CommandCall to create the save file on the system. The default *Public authority is *EXCLUDE. Use the setSaveFilePublicAuthority() method to change the *Public authority value specified on the create save file command.
No encryption is provided by this class. The userid and password flow un-encrypted to the system. This class is not SSL enabled.
The forward slash is the separator character for paths sent to the FTP server.
The following example puts a save file to the system. 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 step automatically.
AS400 system = new AS400(); AS400FTP ftp = new AS400FTP(system); ftp.put("myData.savf", "/QSYS.LIB/MYLIB.LIB/MYDATA.SAVF");
Field Summary |
---|
Fields inherited from class com.ibm.as400.access.FTP |
---|
ACTIVE_MODE, ASCII, BINARY, PASSIVE_MODE |
Constructor Summary | |
---|---|
AS400FTP()
Constructs an AS400FTP object. |
|
AS400FTP(AS400 system)
Constructs an AS400FTP object. |
Method Summary | |
---|---|
boolean |
append(File sourceFileName,
String targetFileName)
Appends to a file on the system. |
OutputStream |
append(String fileName)
Starts the process of appending to a file on the system. |
boolean |
append(String sourceFileName,
String targetFileName)
Appends to a file on the system. |
boolean |
cd(String directory)
Sets the current directory on the system to directory. |
boolean |
connect()
Connects to the system. |
String[] |
dir()
Lists the contents of the current working directory. |
String[] |
dir(String criteria)
Lists the contents of the current directory. |
InputStream |
get(String fileName)
Starts the process of getting a file from the system. |
boolean |
get(String sourceFileName,
File targetFile)
Gets a file from the system. |
boolean |
get(String sourceFileName,
String targetFileName)
Gets a file from the system. |
String |
getCurrentDirectory()
Returns the current directory on the system. |
String |
getSaveFilePublicAuthority()
Returns the public authority of save files created by this object. |
AS400 |
getSystem()
Returns the name of the system. |
String |
issueCommand(String cmd)
Sends a command to the system, returning the reply from the system. |
String[] |
ls()
Lists the contents of the current working directory. |
String[] |
ls(String criteria)
Lists the contents of the current directory. |
boolean |
noop()
Sends the NOOP (no operation) command to the system. |
boolean |
put(File sourceFileName,
String targetFileName)
Puts a file to the system. |
OutputStream |
put(String fileName)
Starts the process of putting a file to the system. |
boolean |
put(String sourceFileName,
String targetFileName)
Puts a file to the system. |
String |
pwd()
Returns the current directory on the system. |
boolean |
setCurrentDirectory(String directory)
Sets the current directory on the system to directory. |
void |
setDataTransferType(int transferType)
Sets the data transfer type. |
void |
setPassword(String password)
Calling setPassword() is valid only for FTP objects. |
void |
setSaveFilePublicAuthority(String publicAuthority)
Sets the public authority of save files created by this object. |
void |
setServer(String server)
Calling setServer() is valid only for FTP objects. |
void |
setSystem(AS400 system)
Sets the name of the system. |
void |
setUser(String user)
Calling setUser() is valid only for FTP objects. |
Methods inherited from class com.ibm.as400.access.FTP |
---|
addFTPListener, addPropertyChangeListener, addVetoableChangeListener, disconnect, finalize, generateNewName, getBufferSize, getLastMessage, getMode, getPort, getServer, getUser, isReuseSocket, removeFTPListener, removePropertyChangeListener, removeVetoableChangeListener, ren, setBufferSize, setMode, setPort, setReuseSocket |
Methods inherited from class java.lang.Object |
---|
clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public AS400FTP()
setSystem(com.ibm.as400.access.AS400)
public AS400FTP(AS400 system)
system
- The system to which to connect.Method Detail |
---|
public OutputStream append(String fileName) throws IOException
append
in class FTP
fileName
- The file to put.
IOException
- If an error occurs while communicating with the system.public boolean append(String sourceFileName, String targetFileName) throws IOException
append
in class FTP
sourceFileName
- The file to put.targetFileName
- The file on the system.
IOException
- If an error occurs while communicating with the system.public boolean append(File sourceFileName, String targetFileName) throws IOException
append
in class FTP
sourceFileName
- The file to put.targetFileName
- The file on the system.
IOException
- If an error occurs while communicating with the system.public boolean cd(String directory) throws IOException
cd
in class FTP
directory
- The current directory to set on the system.
IOException
- If an error occurs while communicating with the system.public boolean connect() throws UnknownHostException, IOException, IllegalStateException
connect
in class FTP
UnknownHostException
- If a path to the system cannot be found.
IOException
- If an error occurs while connecting to the system.
IllegalStateException
- If called before user and password are set.setSystem(com.ibm.as400.access.AS400)
public String[] dir() throws IOException
dir
in class FTP
IOException
- If an error occurs while communicating with the system.public String[] dir(String criteria) throws IOException
dir
in class FTP
criteria
- The search criteria.
IOException
- If an error occurs while communicating with the system.public InputStream get(String fileName) throws IOException, FileNotFoundException
get
in class FTP
fileName
- The file to get.
IOException
- If an error occurs while communicating with the system.
FileNotFoundException
- If the name is a directory or the name is not found.public boolean get(String sourceFileName, String targetFileName) throws IOException, FileNotFoundException
get
in class FTP
sourceFileName
- The file to get on the system.targetFileName
- The file on the target file system.
IOException
- If an error occurs while communicating with the system.
FileNotFoundException
- If the source file or the targe file
cannot be accessed.public boolean get(String sourceFileName, File targetFile) throws IOException, FileNotFoundException
get
in class FTP
sourceFileName
- The file to get on the system.targetFile
- The file on the target file system.
IOException
- If an error occurs while communicating with the system.
FileNotFoundException
- If the source file or the targe file
cannot be accessed.public String getCurrentDirectory() throws IOException
getCurrentDirectory
in class FTP
IOException
- If an error occurs while communicating with the system.public String getSaveFilePublicAuthority()
public AS400 getSystem()
public String issueCommand(String cmd) throws IOException
The command is not altered before sending it to the system, so it must be recognized by the system. Many FTP applications change commands so they are recognized by the system. For example, the command to get a list of files from the system is NLST, not ls. Many FTP applications convert ls to NLST before sending the command to the system. This method will not do the conversion.
issueCommand
in class FTP
cmd
- The command to send to the system.
IOException
- If an error occurs while communicating with the system.public String[] ls() throws IOException
ls
in class FTP
IOException
- If an error occurs while communicating with the system.public String[] ls(String criteria) throws IOException
ls
in class FTP
criteria
- The search criteria.
IOException
- If an error occurs while communicating with the system.public boolean noop() throws IOException
noop
in class FTP
IOException
- If an error occurs while communicating with the system.public OutputStream put(String fileName) throws IOException
put
in class FTP
fileName
- The file to put.
IOException
- If an error occurs while communicating with the system.public boolean put(String sourceFileName, String targetFileName) throws IOException
put
in class FTP
sourceFileName
- The file to put.targetFileName
- The file on the system.
IOException
- If an error occurs while communicating with the system.public boolean put(File sourceFileName, String targetFileName) throws IOException
put
in class FTP
sourceFileName
- The file to put.targetFileName
- The file on the system.
IOException
- If an error occurs while communicating with the system.public String pwd() throws IOException
pwd
in class FTP
IOException
- If an error occurs while communicating with the system.public boolean setCurrentDirectory(String directory) throws IOException
setCurrentDirectory
in class FTP
directory
- The current directory to set on the system.
IOException
- If an error occurs while communicating with the system.public void setDataTransferType(int transferType) throws IOException
If a connection does not already exist, a connection is made to the system. The message returned from the system is saved. Use getLastMessage() to retrieve it.
setDataTransferType
in class FTP
IOException
- If an error occurs while communicating with the system.public void setPassword(String password)
setPassword
in class FTP
password
- The password for the user.public void setSaveFilePublicAuthority(String publicAuthority) throws PropertyVetoException
Valid values are:
The default value is *EXCLUDE
publicAuthority
- *PUBLIC authority.
PropertyVetoException
- If the change is vetoed.public void setServer(String server) throws PropertyVetoException
setServer
in class FTP
server
- The name of the system to which this object connects.
PropertyVetoException
- If the change is vetoed.public void setSystem(AS400 system) throws PropertyVetoException
system
- The name of the system to which this object connects.
PropertyVetoException
- If the change is vetoed.public void setUser(String user) throws PropertyVetoException
setUser
in class FTP
user
- The user identifier used when connecting to the system.
PropertyVetoException
- If the change is vetoed.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |