NpsFtp used to run ftp command.
The sample code indicate how to download log file from www.jwebstar.com
|
var ftp = new NpsFtp(); ftp.Connect('www.jwebstar.com',21); ftp.Login('nps','nps'); ftp.ChangeWorkingDirectory('/pub'); ftp.SetBinary(); ftp.MGet(new NpsFile('/jwebstarlog/'),'jwebstar*.log'); ftp.Disconnect(); |
|
NpsFtp() Construction |
|
| void |
Connect(String server,int port) throws Exception Connect to ftp server |
| void |
Login(String uname,String upass) throws IOException Login to the FTP server using the provided username and password. |
| void |
ChangeWorkingDirectory(String path) throws IOException Change the current working directory of the FTP session. |
| String |
PrintWorkingDirectory() throws IOException Returns the pathname of the current working directory. |
| boolean |
MkDir(String path) throws IOException Creates a new subdirectory on the FTP server in the current directory(if a relative pathname is given) or where specified (if an absolute pathname is given). |
| void |
MkDirs(String path) throws IOException Creates the directory named by this abstract path, including any necessary but nonexistent parent directories. |
| boolean |
RemoveDir(String path) throws IOException Removes a directory on the FTP server (if empty). |
| void |
SetAscii() throws IOException Sets the file type to ASCII. |
| void |
SetBinary() throws IOException Sets the file type to BINARY.The default file type is ASCII if this method is never called. |
| boolean |
Get(String filename,NpsFile local) throws Exception Retrieves a file named filename from the server,and writes it to local. |
| void |
MGet(NpsFile local_dir,String filter) throws Exception Retrieves files or directories from the server,and writes it to local dir. filter is the conditions, you can use the DOS format of the wildcard, * can replace the file name in the number of characters, and ? can only replace the file name of a character. for example:"*.doc" mean get all files ends with ".doc" from ftp server. |
| void |
Put(NpsFile local) throws Exception Stores a file to the server. |
| void |
MPut(NpsFile local_dir,String filter) throws Exception Stores all files or directories in local_dir to the server. filter is the conditions, you can use the DOS format of the wildcard, * can replace the file name in the number of characters, and ? can only replace the file name of a character. for example:"*.doc" mean put all files ends with ".doc" in local_dir to the ftp server |
| void |
Delete(String filename) throws IOException Deletes a file on the FTP server. |
| boolean |
Rename(String from,String to) throws IOException Renames a remote file. |
| void |
Logout() throws IOException Logout of the FTP server by sending the QUIT command. |
| void |
Disconnect() throws IOException Closes the connection to the FTP server and restores connection parameters to the default values. |
| void |
Abort() throws IOException Abort a transfer in progress. |