Class FtpLocation


  • public class FtpLocation
    extends java.lang.Object
    Encapsulates the location of a directory on an FTP server.
    • Constructor Summary

      Constructors 
      Constructor Description
      FtpLocation​(java.lang.String loc)
      Constructs a new FtpLocation from a URL-like string.
      FtpLocation​(FtpLocation floc, java.lang.String path)
      Constructs a new FtpLocation based on this one.
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      java.net.URL getBaseURL()
      Returns a URL representing the connection used by this object.
      org.apache.commons.net.ftp.FTPClient getClient()
      Returns an FTP client for use at this location from a public pool.
      FtpLocation getParent()
      Returns the FtpLocation representing the parent directory of this one, if it has one.
      java.lang.String getPath()
      Returns the full directory path for this node.
      java.net.URL getURL()
      Returns the URL representing this directory.
      • Methods inherited from class java.lang.Object

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

      • FtpLocation

        public FtpLocation​(java.lang.String loc)
                    throws NoSuchDataException
        Constructs a new FtpLocation from a URL-like string. The string must be of the form "ftp://[user[:password]@]hostname[:port]path" where path is a '/'-separated absolute pathname of a directory on the server.
        Parameters:
        loc - url of the ftp directory
        Throws:
        NoSuchDataException
      • FtpLocation

        public FtpLocation​(FtpLocation floc,
                           java.lang.String path)
                    throws NoSuchDataException
        Constructs a new FtpLocation based on this one. The same host and authentication information will be used, but the directory location is specified by the path argument, which may be either absolute (starting with a '/') or relative to this object's path.
        Parameters:
        floc - the object from which to copy connection information
        path - the absolute or relative path of the new location object
        Throws:
        NoSuchDataException
    • Method Detail

      • getPath

        public java.lang.String getPath()
        Returns the full directory path for this node.
        Returns:
        pathname of directory in ftp filesystem
      • getBaseURL

        public java.net.URL getBaseURL()
        Returns a URL representing the connection used by this object. This contains the host, but not the path to the directory.
        Returns:
        connection URL
      • getURL

        public java.net.URL getURL()
        Returns the URL representing this directory.
        Returns:
        directory URL
      • getParent

        public FtpLocation getParent()
        Returns the FtpLocation representing the parent directory of this one, if it has one. If it has no parent (presumably because it is the root) null is returned.
        Returns:
        parent location, or null
      • getClient

        public org.apache.commons.net.ftp.FTPClient getClient()
                                                       throws java.io.IOException
        Returns an FTP client for use at this location from a public pool. In general the pool keeps only one client for each host. Such clients may be in use by more than one thread at a time, so you should synchronise on them when performing a sequence of commands. Steps are taken to ensure that the returned client is not timed out (and is not just about to be).
        Returns:
        a pooled client usable at this location
        Throws:
        java.io.IOException