common-util

local.tomas.util.net
Class FtpClient

java.lang.Object
  extended by local.tomas.util.net.BaseClient
      extended by local.tomas.util.net.FtpClient

public class FtpClient
extends BaseClient

Title: FTP Client Description: Copyright: Copyright (c) 2001 Company:

Version:
1.0
Author:
Tomas Teubner

Nested Class Summary
 
Nested classes/interfaces inherited from class local.tomas.util.net.BaseClient
BaseClient.NetAck
 
Field Summary
 
Fields inherited from class local.tomas.util.net.BaseClient
cmd, cmdIn, cmdOut
 
Constructor Summary
FtpClient()
          Default constructor.
 
Method Summary
 void ascii()
          Switch to text mode.
 void bin()
          Switch to binary mode.
 void cdup()
          Change working directory on server to parent directory.
 void close()
          Close connection.
 void connect(String host)
          Connect to host on default FTP port.
 void cwd(String wd)
          Change working directory on server.
 void delete(String fileName)
          Remove remote file.
 String getwd()
          Get current remote working directory.
 InputStream list(String fileName)
          List remote files.
 void login(String user, String password)
          Login to FTP server.
 void mkdir(String dirName)
          Create remote directory.
 Iterator<String> nameList(String fileName)
          Iterate over list of remote files.
 void noop()
          Send no operation command.
 void port(InetAddress addr, int port)
          Send port command.
 void rename(String from, String to)
          Rename remote file.
 InputStream retrieve(String fileName)
          Open remote file for retrieval.
 void rmdir(String dirName)
          Remove remote directory.
 OutputStream send(String fileName)
          Open output stream to remote file.
 
Methods inherited from class local.tomas.util.net.BaseClient
connect, getAck, sendCommand
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

FtpClient

public FtpClient()
Default constructor.

Method Detail

connect

public void connect(String host)
             throws NetException
Connect to host on default FTP port.

Parameters:
host -
Throws:
NetException

login

public void login(String user,
                  String password)
           throws NetException
Login to FTP server.

Parameters:
user - user name
password - password
Throws:
NetException

close

public void close()
           throws NetException
Description copied from class: BaseClient
Close connection.

Overrides:
close in class BaseClient
Throws:
NetException

cwd

public void cwd(String wd)
         throws NetException
Change working directory on server.

Parameters:
wd - new working directory
Throws:
NetException

cdup

public void cdup()
          throws NetException
Change working directory on server to parent directory.

Throws:
NetException

port

public void port(InetAddress addr,
                 int port)
          throws NetException
Send port command.

Parameters:
addr - address of port
port - port number
Throws:
NetException

noop

public void noop()
          throws NetException
Send no operation command.

Throws:
NetException

bin

public void bin()
         throws NetException
Switch to binary mode.

Throws:
NetException

ascii

public void ascii()
           throws NetException
Switch to text mode.

Throws:
NetException

retrieve

public InputStream retrieve(String fileName)
                     throws NetException
Open remote file for retrieval.

Parameters:
fileName - remote file name
Returns:
input stream to file
Throws:
NetException

send

public OutputStream send(String fileName)
                  throws NetException
Open output stream to remote file.

Parameters:
fileName - remote file name
Returns:
output stream
Throws:
NetException

list

public InputStream list(String fileName)
                 throws NetException
List remote files.

Parameters:
fileName - directory name or null if current directory
Returns:
stream listing files
Throws:
NetException

nameList

public Iterator<String> nameList(String fileName)
                          throws NetException
Iterate over list of remote files.

Parameters:
fileName - directory name or null if current directory
Returns:
iterator over files
Throws:
NetException

rename

public void rename(String from,
                   String to)
            throws NetException
Rename remote file.

Parameters:
from - old name
to - new name
Throws:
NetException

delete

public void delete(String fileName)
            throws NetException
Remove remote file.

Parameters:
fileName - file name
Throws:
NetException

mkdir

public void mkdir(String dirName)
           throws NetException
Create remote directory.

Parameters:
dirName - directory name
Throws:
NetException

rmdir

public void rmdir(String dirName)
           throws NetException
Remove remote directory.

Parameters:
dirName - directory name
Throws:
NetException

getwd

public String getwd()
             throws NetException
Get current remote working directory.

Returns:
directory name
Throws:
NetException

common-util

Copyright © 2005-2007 Tomas Teubner. All Rights Reserved.