FtpBean

This is a Ftp Bean which provide basic ftp client functions (eg. get or put ascii/binary file, delete file, rename file, change directory ...... etc). It is written in Java1.1 code and it is free for anyone to use it and distribute it.

Update

version 1.4.5 or later

  1. I am NOT going to update the 'Update' section for this page (i am lazy) anymore. Please download the files and see the history header in the source code if you are interested.

version 1.4.4 - 10, March 2001

  1. Fixed bug on the getPassiveSocket method which pass incorrect server and port information when using the SocketOpener class for openning new socket.
  2. Fixed bug on the getDataSocket method where the ServerSocket is not closed when using active mode transfer. This may cause problem if there are too many ServerSocket opened.
  3. Fixed bug on most of the get/put file methods where the setTransferType is not enclosed in the "try" block.
  4. Fix bug on parsing DOS format list with name contains more than 1 space.
  5. Fix bug on parsing UNIX format list with the first word of the name is also contains in the date or size.

version 1.4.3 - 31, Jan 2001

  1. Increase code efficiency for private method getBytes(BufferedInputStream, FtpObserver). This increase the of those get file methods that return a byte array or String.
  2. Private method getPassiveDataSocket() changed, so that it read the ip address returned from the PASV command rather than using the getServerName method as the host. 3
  3. Added the SocketOpener class to deal with add timeout feature for openning Socket.
  4. Changed the way to get new Socket in ftpConnect and getPassiveSocket methods to support * the timeout feature if it is being set.
  5. Public method getSocketTimeout() added.
  6. Public method setSocketTimeout(int) added.
  7. Public method getAsciiFile(String, String, String) added.
  8. Public method getAsciiFile(String, String, String, FtpObserver) added.

version 1.4.2 - 1, Aug 2000

  1. Fixed bug on dead lock in close() method when sing putBinaryFile(String, String) to upload a non-existing local file.
  2. Fixed bug on parsing list with file name contains more than 1 space.

version 1.4.1 - 19, May 2000

  1. Fixed bug on FtpListResult class.
  2. Fixed bug on dead lock may caused by active mode data transfer.
  3. Fixed bug on dead lock may caused by passive mode datat transfer.
  4. Public method execute() added.
  5. Public methd getSystemType added.

version 1.4 - 19, April 2000

  1. New interface FtpObserver added.
  2. New class FtpListResultBeanInfo added.
  3. FtpListResult can parse for MS-DOS format list now.
  4. Added methods to FtpBean to support the FtpObserver interface.

version 1.3.2 - 10, February 2000

  1. Fixed bug on FtpListResult class.

version 1.3.1 - 1, February 2000

  1. Fixed bug on deadlock during incorrect login.
  2. Fixed bug on FtpListResult class.

version 1.3 - 20,January 2000

  1. New class FtpListResult added.
  2. Public method getDirectoryContent() changed to getDirectoryContentAsString().
  3. Public method getPassiveModeTransfer() changed to isPassiveModeTransfer().
  4. Public method getDirectoryContent() added.
  5. Thread safe.
  6. Private method aquire added.
  7. Private method release added.

version 1.2 - 6, Nov 1999

  1. Public method putBinaryFile(String, String) added.
  2. Public method putBinaryFile(String, String, long) added.
  3. Public method getReply() added.
  4. Public method getAsciiFile(String) changed to getAsciiFile(String, String).
  5. Public method putAsciiFile(String, String) changed to putAsciiFile(String, String, String).
  6. Public method getPassive() changed to getPassiveModeTransfer().
  7. Public method setPassive(boolean) changed to putPassiveModeTransfer(boolean).
  8. Debug mode supported

version 1.1 - 21, Aug 1999

  1. Provide active data transfer mode (Using PORT command).
  2. Public method setPassive(boolean) added.
  3. Public method getPassive() added.
  4. Fixed bug on getting binary file on a restarting point as a byte array.

Package

There are five classes and one interface in the bean, all belong to the package "ftp", they are:

classes:

ftp.FtpBean
The main class which provide basic operation.
ftp.FtpException
The exception which will be threw for any non-successful operation (eg. you want to get a file from the server through ftp but the file doesn't exist or permission denied.).
ftp.FtpListResult
A class for parsing information from the result of ftp LIST command.
ftp.FtpBeanBeanInfo
Bean info class for FtpBean. This is only for some visual IDE (eg. IBM Visual Age) to better understand the bean.
ftp.FtpListResultBeanInfo
Bean info class for FtpListResult. This is only for some visual IDE (eg. IBM Visual Age) to better understand the bean.
ftp.FtpReplyResourceBundle
Resource bundle that contains valid reply code for various ftp commands.

interfaces:

ftp.FtpObserver
Classes that implement this inteface can have the ability to monitor the progress of some uploading and downloading process.

Features

  1. Connect to ftp host.
  2. Passive and active data transmission.
  3. File delete.
  4. File rename.
  5. Get and put ascii files.
  6. Get and put binary files.
  7. Get and put binary files with a restarting point.
  8. Get directory name (PWD).
  9. Change directory (CWD).
  10. Make directory.
  11. Remove directory.
  12. Set port number.
  13. Get port number.
  14. Get host name.
  15. Get remote system types
  16. Get user name.
  17. Get reply from server.
  18. Get reply message from server.
  19. Execute command via ftp.
  20. Thread safe.
  21. Parsing information from the LIST command including file name, file size, owner, group and permission.
  22. Monitor the uploading and downloading process of the bean.

Coming Goals

  1. Implement methods to handle ascii files but not use too many memory.
  2. File name filter for parsing list
  3. Server to server transmission.
  4. Maintain backward compability.

Requirment

JDK 1.1 compatible Java Virtual Machine.

Platform

It is written in pure Java. So it can be run on any supported platform.

Download

This FtpBean is free to download and use. The last version is 1.4.5

You are welcomed to download, it includes class files, a jar file, source code and documentation:

Last version
Windows zip format

UNIX compressed tar ball

Old versions
1.4.4
Window zip format
UNIX compressed tar ball

1.4.3
Window zip format
UNIX compressed tar ball

1.4.2
Windows zip format
UNIX compressed tar ball

Thanks

Thanks for Wayne Conrad who provides the SocketOpener class.

Special Thanks for the following persons pointed out some bugs or gave useful suggestions on this bean:
Niels Ull Harremoes
Minzhuan Gong
igor
Morris Cavan
Vincent Mahon
Brian Wohlin
Todd Gleason
Josef Gierbl
Todd Kirby
Niels Harremoes
szetoo yutit
Clinton Bosch
Stephen Porterfield
Russell Gold
Victor Mikhailov
Thomson Danielle
Martin Crawford
Mahesh Sharma
Steve Stock
Jorge Gayo
Rob Desilets

Dave Slaughter
Lars Uhver
Wes
Gary Peskin
David Buchwald
Thomas Angioletti
Brian Wohlin


Please send me an e-mail if you have any comments on it or you find it useful. Thanks

Back to HOME