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