Class FTPCache

java.lang.Object
org.deltava.util.ftp.FTPCache

public class FTPCache extends Object
A utility class to provide cached access to a remote FTP server.
Since:
1.0
Version:
11.1
Author:
Luke
  • Constructor Details

    • FTPCache

      public FTPCache(String path)
      Initializes the FTP cache bean.
      Parameters:
      path - the local cache directory
  • Method Details

    • setHost

      public void setHost(String host)
      Sets the host name of the remote FTP server.
      Parameters:
      host - the FTP server host name
    • setCredentials

      public void setCredentials(String user, String pwd)
      Sets the credentials used to connect to the remote FTP server.
      Parameters:
      user - the user ID
      pwd - the password
    • getDownloadInfo

      public FTPDownloadData getDownloadInfo()
      Returns data about the last file downloaded.
      Returns:
      an FTPDownloadData bean, or null if no file downloaded
    • getNewest

      public String getNewest(String dirName, FilenameFilter filter)
      Returns the newest file on the remote server.
      Parameters:
      dirName - the directory on the server
      filter - a FilenameFilter or null if none
      Returns:
      the file name, or null if no files found
      See Also:
    • getFile

      public InputStream getFile(String fileName) throws FTPClientException
      Checks the cache for a file, and downloads a new copy if not found or the remote copy is newer.
      Parameters:
      fileName - the file name
      Returns:
      an InputStream to the file data
      Throws:
      FTPClientException - if an error occurs