Class FTPClient

java.lang.Object
com.compomics.util.io.ftp.FTPClient

public class FTPClient
extends Object
This class implements a 'directory listener' to listen for new files and ftp them to a remote FTP server.
This class uses the implementation found on the web for an FTP client.
Author:
Lennart Martens
  • Constructor Summary

    Constructors 
    Constructor Description
    FTPClient()
    Empty default constructor
    FTPClient​(String aHost, String aUser, String aPassword)
    Constructor that takes the three parameters necessary for the FTP connection.
  • Method Summary

    Modifier and Type Method Description
    void sendBinaryFile​(String aFilename)
    This method sends a binary file to the default FTP location on the server.
    void sendFiles​(String[] aFilenames, boolean aBinaryMode)
    This method sends a group of files to the default FTP location on the server.
    void sendFiles​(String[] aFilenames, boolean[] aBinaryMode)
    This method sends a group of files to the default FTP location on the server.
    void sendTextFile​(String aFilename)
    This method sends a text file to the default FTP location on the server.
    void testFTPConnection()
    This method can be used to test the connection with the FTP server.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Constructor Details

    • FTPClient

      public FTPClient()
      Empty default constructor
    • FTPClient

      public FTPClient​(String aHost, String aUser, String aPassword)
      Constructor that takes the three parameters necessary for the FTP connection. Note that in FTP, passwords are typically sent in plain text!!!
      Parameters:
      aHost - String with the hostname of the FTP server to connect to.
      aUser - String with the username to connect with.
      aPassword - String with the password for the specified user.
  • Method Details

    • sendTextFile

      public void sendTextFile​(String aFilename) throws IOException
      This method sends a text file to the default FTP location on the server.
      Parameters:
      aFilename - String with the filename to send.
      Throws:
      IOException - when retrieving the file fails, or sending the file failed.
    • sendBinaryFile

      public void sendBinaryFile​(String aFilename) throws IOException
      This method sends a binary file to the default FTP location on the server.
      Parameters:
      aFilename - String with the filename to send.
      Throws:
      IOException - when retrieving the file fails, or sending the file failed.
    • sendFiles

      public void sendFiles​(String[] aFilenames, boolean[] aBinaryMode) throws IOException
      This method sends a group of files to the default FTP location on the server. It also allows the specification of binary or text mode.
      Parameters:
      aFilenames - String[] with the filenames of the files to send.
      aBinaryMode - boolean[] to indicate whether the files are to be send in binary transfer mode ('true') or text mode ('false'). Note that this setting applies to all files in the group.
      Throws:
      IOException - when retrieving the file fails, or sending the file failed.
    • sendFiles

      public void sendFiles​(String[] aFilenames, boolean aBinaryMode) throws IOException
      This method sends a group of files to the default FTP location on the server. It also allows the specification of binary or text mode.
      Parameters:
      aFilenames - String[] with the filenames of the files to send.
      aBinaryMode - boolean to indicate whether the files are to be send in binary transfer mode ('true') or text mode ('false'). Note that this setting applies to all files in the group.
      Throws:
      IOException - when retrieving the file fails, or sending the file failed.
    • testFTPConnection

      public void testFTPConnection() throws IOException
      This method can be used to test the connection with the FTP server.
      Throws:
      IOException - whenever a connection could not be established.