sun.net.ftp
Class FtpClient

java.lang.Object
  extended by sun.net.NetworkClient
      extended by sun.net.TransferProtocolClient
          extended by sun.net.ftp.FtpClient

public class FtpClient
extends TransferProtocolClient

This class implements the FTP client.


Field Summary
static int FTP_PORT
           
static String ftpProxyHost
          Deprecated.  
static int ftpProxyPort
          Deprecated.  
static boolean useFtpProxy
          Deprecated.  
 String welcomeMsg
          Welcome message from the server, if any.
 
Fields inherited from class sun.net.TransferProtocolClient
serverResponse
 
Fields inherited from class sun.net.NetworkClient
defaultConnectTimeout, defaultSoTimeout, encoding, serverInput, serverOutput, serverSocket
 
Constructor Summary
FtpClient()
          Create an uninitialized FTP client.
FtpClient(String host)
          New FTP client connected to host host.
FtpClient(String host, int port)
          New FTP client connected to host host, port port.
 
Method Summary
 void ascii()
          Set transfer type to 'A'
 void binary()
          Set transfer type to 'I'
 void cd(String remoteDirectory)
          CD to a specific directory on a remote FTP server
 void closeServer()
          issue the QUIT command to the FTP server and close the connection.
 TelnetInputStream get(String filename)
          GET a file from the FTP server
static String getFtpProxyHost()
           
static int getFtpProxyPort()
           
static boolean getUseFtpProxy()
           
protected  int issueCommand(String cmd)
           
protected  void issueCommandCheck(String cmd)
           
 TelnetInputStream list()
          LIST files on a remote FTP server
 void login(String user, String password)
          login user to a host with username user and password password
protected  Socket openDataConnection(String cmd)
           
 void openServer(String host)
          open a FTP connection to host host.
 void openServer(String host, int port)
          open a FTP connection to host host on port port.
 TelnetOutputStream put(String filename)
          PUT a file to the FTP server
protected  int readReply()
           
 
Methods inherited from class sun.net.TransferProtocolClient
getResponseString, getResponseStrings, readServerResponse, sendServer
 
Methods inherited from class sun.net.NetworkClient
doConnect, getLocalAddress, serverIsOpen
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

FTP_PORT

public static final int FTP_PORT
See Also:
Constant Field Values

welcomeMsg

public String welcomeMsg
Welcome message from the server, if any.


useFtpProxy

public static boolean useFtpProxy
Deprecated. 

ftpProxyHost

public static String ftpProxyHost
Deprecated. 

ftpProxyPort

public static int ftpProxyPort
Deprecated. 
Constructor Detail

FtpClient

public FtpClient(String host)
          throws IOException
New FTP client connected to host host.

Throws:
IOException

FtpClient

public FtpClient(String host,
                 int port)
          throws IOException
New FTP client connected to host host, port port.

Throws:
IOException

FtpClient

public FtpClient()
Create an uninitialized FTP client.

Method Detail

getUseFtpProxy

public static boolean getUseFtpProxy()
Returns:
if the networking layer should send ftp connections through a proxy

getFtpProxyHost

public static String getFtpProxyHost()
Returns:
the host to use, or null if none has been specified

getFtpProxyPort

public static int getFtpProxyPort()
Returns:
the proxy port to use. Will default reasonably if not set.

closeServer

public void closeServer()
                 throws IOException
issue the QUIT command to the FTP server and close the connection.

Overrides:
closeServer in class NetworkClient
Throws:
IOException

issueCommand

protected int issueCommand(String cmd)
                    throws IOException
Throws:
IOException

issueCommandCheck

protected void issueCommandCheck(String cmd)
                          throws IOException
Throws:
IOException

readReply

protected int readReply()
                 throws IOException
Throws:
IOException

openDataConnection

protected Socket openDataConnection(String cmd)
                             throws IOException
Throws:
IOException

openServer

public void openServer(String host)
                throws IOException
open a FTP connection to host host.

Throws:
IOException

openServer

public void openServer(String host,
                       int port)
                throws IOException
open a FTP connection to host host on port port.

Overrides:
openServer in class NetworkClient
Throws:
IOException

login

public void login(String user,
                  String password)
           throws IOException
login user to a host with username user and password password

Throws:
IOException

get

public TelnetInputStream get(String filename)
                      throws IOException
GET a file from the FTP server

Throws:
IOException

put

public TelnetOutputStream put(String filename)
                       throws IOException
PUT a file to the FTP server

Throws:
IOException

list

public TelnetInputStream list()
                       throws IOException
LIST files on a remote FTP server

Throws:
IOException

cd

public void cd(String remoteDirectory)
        throws IOException
CD to a specific directory on a remote FTP server

Throws:
IOException

binary

public void binary()
            throws IOException
Set transfer type to 'I'

Throws:
IOException

ascii

public void ascii()
           throws IOException
Set transfer type to 'A'

Throws:
IOException