All Packages  This Package  Class Hierarchy  Class Search  Index

Class kh.net.FtpClient
java.lang.Object
   |
   +----kh.net.FtpClient

  Summary

public class  FtpClient
     extends java.lang.Object
{
          // Constructors 2
     public FtpClient(String) throws IOException;
     public FtpClient(URL) throws IOException;

          // Methods 9
     public void close();
     public void doCommand(String) throws IOException;
     public synchronized InputStream doInputPort(String, boolean) throws IOException;
     public synchronized OutputStream doOutputPort(String) throws IOException;
     public String doPWD() throws IOException;
     public FtpFile getCWD();
     public void listFiles() throws IOException;
     public void setCWD(String) throws IOException;
     public void setCWD(FtpFile) throws IOException;
}

This class provides an FTP client which is substantially extended beyond the basic Sun FTP URL support. It supports auto login with password. It also allows the creation of FtpFile - a filesystem independent fake filesystem.

This code is based on the Ftp.java file by Joseph Szabo: jszabo@remus.rutgers.edu




  Constructors

· FtpClient

Summary  |  Top

   public FtpClient(String serverName)  throws IOException

Construct a client side link - given a hostname No login is done



· FtpClient

Summary  |  Top
   public FtpClient(URL url)  throws IOException

Construct a client side link - given an FTP url. This class accepts an enhanced url which hides the username and password in the 'ref' section of the URL. An example would be: ftp://interstice.com/~kevinh#kevinh/fish This would: 1) connect to interstice.com. 2) USER kevinh (if unspecified - then anonymous is used) 3) PASS fish (if unspecified - then guest is used) 4) CWD ~kevinh



  Methods

· close

Summary  |  Top
   public void close() 

Destroy a link



· doCommand

Summary  |  Top
   public void doCommand(String command)  throws IOException

Does a single simple command



· doInputPort

Summary  |  Top
   public synchronized InputStream doInputPort(String command, 
                                               boolean binaryMode)  throws IOException

Performs downloading commands that need a data port. Tells server which data port it will listen on, then sends command on control port, then listens on data port for server response.

Parameter Description
command list, nlist, or retr plus arguments
binaryMode true if the file should be sent as binary

Returns:
the data from the port


· doOutputPort

Summary  |  Top
   public synchronized OutputStream doOutputPort(String command)  throws IOException

Upload a file in binary mode.

Parameter Description
command stor or stou plus arguments



· doPWD

Summary  |  Top
   public String doPWD()  throws IOException

Read the current directory from the other side



· getCWD

Summary  |  Top
   public FtpFile getCWD() 

Get the current directory



· listFiles

Summary  |  Top
   public void listFiles()  throws IOException

Print the contents of the current directory



· setCWD

Summary  |  Top
   public void setCWD(String direct)  throws IOException

Change current directory



· setCWD

Summary  |  Top
   public void setCWD(FtpFile cwd)  throws IOException

Set the current directory - recursively constructing the full path



All Packages  This Package  Class Hierarchy  Class Search  Index
Freshly brewed Java API Documentation automatically generated with polardoc Version 1.0.7