javatools.ftp
Class FTPClientImpl

java.lang.Object
  |
  +--javatools.ftp.FTPClientImpl
All Implemented Interfaces:
FTPClient

public class FTPClientImpl
extends java.lang.Object
implements FTPClient

An FTP client class which implements remote peer-to-peer transfer.


Field Summary
(package private)  java.lang.String code
           
(package private)  java.net.Socket controlSocket
           
(package private)  java.lang.String host
           
(package private)  java.io.BufferedReader is
           
(package private)  int localDataPort
           
(package private)  java.net.InetAddress localInetAddress
           
(package private)  boolean Mode
           
(package private)  java.io.BufferedWriter ps
           
(package private)  java.lang.String response
           
(package private)  java.lang.String user
           
 
Fields inherited from interface javatools.ftp.FTPClient
DIRECTORY, FILE, GETFILE, GETLIST, LINK, UNKNOWN
 
Constructor Summary
FTPClientImpl()
           
 
Method Summary
 long bytesTransf()
          Gets the number of bytes read
 void cwd(java.lang.String dir)
          Change to the specified directory, which may be relative or absolute.
 void delete(java.lang.String sDirectory, java.lang.String sFile)
          Delete the File
(package private)  java.lang.String extractPortAddress(java.lang.String s)
          Parses a port address from the string returned by the "pasv" FTP command.
 java.util.Vector list()
          Request a listing of the current directory.
(package private)  java.lang.String makePortAddress(java.net.InetAddress inad, int port)
          Manufacture the kind of host/port address required by FTP.
 void openConnection(java.lang.String host, java.lang.String user, java.lang.String password)
          Open a connection to a remote host that runs an FTP server.
 void quit()
          Close ftp connection
 void readResponse()
          Read a response from the host.
 void receive(java.lang.String directory, java.lang.String filename, FTPVisitor ftpVisitor)
          Request to receive the specified file.
 java.lang.String retResponse()
          Returns FTP server response
 void send(java.lang.String sDirectory, java.lang.String filename, FTPSender ftpSender)
          Request that the host send a file to another host.
 void sendCommand(java.lang.String command)
          Send a command to the host, and read the response.
 void setAscii()
          Set the transfer mode to Ascii.
 void setBinary()
          Set the transfer mode to Image (also referred to as "binary").
(package private)  java.lang.String toUnsignedDecimal(byte b)
          Utility function to convert a byte to an unsigned decimal string representation
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

host

java.lang.String host

user

java.lang.String user

localInetAddress

java.net.InetAddress localInetAddress

localDataPort

int localDataPort

Mode

boolean Mode

response

java.lang.String response

is

java.io.BufferedReader is

ps

java.io.BufferedWriter ps

code

java.lang.String code

controlSocket

java.net.Socket controlSocket
Constructor Detail

FTPClientImpl

public FTPClientImpl()
Method Detail

openConnection

public void openConnection(java.lang.String host,
                           java.lang.String user,
                           java.lang.String password)
                    throws java.io.IOException,
                           java.lang.Exception
Open a connection to a remote host that runs an FTP server.

Specified by:
openConnection in interface FTPClient
java.io.IOException
java.lang.Exception

quit

public void quit()
          throws java.io.IOException,
                 java.lang.Exception
Description copied from interface: FTPClient
Close ftp connection

Specified by:
quit in interface FTPClient
java.io.IOException
java.lang.Exception

sendCommand

public void sendCommand(java.lang.String command)
                 throws java.io.IOException,
                        java.lang.Exception
Send a command to the host, and read the response.

Specified by:
sendCommand in interface FTPClient
java.io.IOException
java.lang.Exception

readResponse

public void readResponse()
                  throws java.io.IOException
Read a response from the host.

Specified by:
readResponse in interface FTPClient
java.io.IOException

makePortAddress

java.lang.String makePortAddress(java.net.InetAddress inad,
                                 int port)
Manufacture the kind of host/port address required by FTP. The syntax is: PORT h1,h2,h3,h4,p1,p2 where h1 is the high order 8 bits of the internet host address.


toUnsignedDecimal

java.lang.String toUnsignedDecimal(byte b)
Utility function to convert a byte to an unsigned decimal string representation


setAscii

public void setAscii()
              throws java.io.IOException,
                     java.lang.Exception
Set the transfer mode to Ascii.

Specified by:
setAscii in interface FTPClient
java.io.IOException
java.lang.Exception

setBinary

public void setBinary()
               throws java.io.IOException,
                      java.lang.Exception
Set the transfer mode to Image (also referred to as "binary").

Specified by:
setBinary in interface FTPClient
java.io.IOException
java.lang.Exception

cwd

public void cwd(java.lang.String dir)
         throws java.io.IOException,
                java.lang.Exception
Change to the specified directory, which may be relative or absolute.

Specified by:
cwd in interface FTPClient
java.io.IOException
java.lang.Exception

delete

public void delete(java.lang.String sDirectory,
                   java.lang.String sFile)
            throws java.io.IOException,
                   java.lang.Exception
Delete the File

Specified by:
delete in interface FTPClient
java.io.IOException
java.lang.Exception

send

public void send(java.lang.String sDirectory,
                 java.lang.String filename,
                 FTPSender ftpSender)
          throws java.io.IOException,
                 java.lang.Exception
Request that the host send a file to another host. The destination host is specified by the port string, which conforms to the syntax used by makePortAddress().

Specified by:
send in interface FTPClient
java.io.IOException
java.lang.Exception

list

public java.util.Vector list()
                      throws java.io.IOException,
                             java.lang.Exception
Request a listing of the current directory. The result is sent on a new data connection.

Specified by:
list in interface FTPClient
java.io.IOException
java.lang.Exception

receive

public void receive(java.lang.String directory,
                    java.lang.String filename,
                    FTPVisitor ftpVisitor)
             throws java.io.IOException,
                    java.lang.Exception
Request to receive the specified file.

Specified by:
receive in interface FTPClient
java.io.IOException
java.lang.Exception

extractPortAddress

java.lang.String extractPortAddress(java.lang.String s)
                              throws java.lang.Exception
Parses a port address from the string returned by the "pasv" FTP command. Assumes that the port address is enclosed in parentheses. Extract it and return it as is.

java.lang.Exception

bytesTransf

public long bytesTransf()
Gets the number of bytes read

Specified by:
bytesTransf in interface FTPClient

retResponse

public java.lang.String retResponse()
Returns FTP server response

Specified by:
retResponse in interface FTPClient