Class FTPFile

<!-- ========= END OF TOP NAVBAR ========= -->

<!-- ======== START OF CLASS DATA ======== -->
org.apache.commons.net.ftp

Class FTPFile

  • <!-- =========== FIELD SUMMARY =========== -->
    • <!-- -->

      Field Summary

      Fields  
      Modifier and TypeField and Description
      static int DIRECTORY_TYPE
      A constant indicating an FTPFile is a directory.
      static int EXECUTE_PERMISSION
      A constant indicating file execute permission or directory listing permission.
      static int FILE_TYPE
      A constant indicating an FTPFile is a file.
      static int GROUP_ACCESS
      A constant indicating group access permissions.
      static int READ_PERMISSION
      A constant indicating file/directory read permission.
      static int SYMBOLIC_LINK_TYPE
      A constant indicating an FTPFile is a symbolic link.
      static int UNKNOWN_TYPE
      A constant indicating an FTPFile is of unknown type.
      static int USER_ACCESS
      A constant indicating user access permissions.
      static int WORLD_ACCESS
      A constant indicating world access permissions.
      static int WRITE_PERMISSION
      A constant indicating file/directory write permission.
    <!-- ======== CONSTRUCTOR SUMMARY ======== -->
    • <!-- -->

      Constructor Summary

      Constructors  
      Constructor and Description
      FTPFile()
      Creates an empty FTPFile.
    <!-- ========== METHOD SUMMARY =========== -->
    • <!-- -->

      Method Summary

      Methods  
      Modifier and TypeMethod and Description
      String getGroup()
      Returns the name of the group owning the file.
      int getHardLinkCount()
      Return the number of hard links to this file.
      String getLink()
      If the FTPFile is a symbolic link, this method returns the name of the file being pointed to by the symbolic link.
      String getName()
      Return the name of the file.
      String getRawListing()
      Get the original FTP server raw listing used to initialize the FTPFile.
      long getSize()
      Return the file size in bytes.
      Calendar getTimestamp()
      Returns the file timestamp.
      int getType()
      Return the type of the file (one of the _TYPE constants), e.g., if it is a directory, a regular file, or a symbolic link.
      String getUser()
      Returns the name of the user owning the file.
      boolean hasPermission(int access,                          int permission)
      Determines if the given access group (one of the _ACCESS constants) has the given access permission (one of the _PERMISSION constants) to the file.
      boolean isDirectory()
      Determine if the file is a directory.
      boolean isFile()
      Determine if the file is a regular file.
      boolean isSymbolicLink()
      Determine if the file is a symbolic link.
      boolean isUnknown()
      Determine if the type of the file is unknown.
      boolean isValid()
      Used to indicate whether an entry is valid or not.
      void setGroup(String group)
      Set the name of the group owning the file.
      void setHardLinkCount(int links)
      Set the number of hard links to this file.
      void setLink(String link)
      If the FTPFile is a symbolic link, use this method to set the name of the file being pointed to by the symbolic link.
      void setName(String name)
      Set the name of the file.
      void setPermission(int access,                          int permission,                          boolean value)
      Set if the given access group (one of the _ACCESS constants) has the given access permission (one of the _PERMISSION constants) to the file.
      void setRawListing(String rawListing)
      Set the original FTP server raw listing from which the FTPFile was created.
      void setSize(long size)
      Set the file size in bytes.
      void setTimestamp(Calendar date)
      Set the file timestamp.
      void setType(int type)
      Set the type of the file ( DIRECTORY_TYPE, FILE_TYPE, etc.).
      void setUser(String user)
      Set the name of the user owning the file.
      String toFormattedString()
      Returns a string representation of the FTPFile information.
      String toFormattedString(String timezone)
      Returns a string representation of the FTPFile information.
      String toString()
      Returns a string representation of the FTPFile information.
  • <!-- ============ FIELD DETAIL =========== --> <!-- ========= CONSTRUCTOR DETAIL ======== -->
    • <!-- -->

      Constructor Detail

      <!-- -->
      • FTPFile
        public FTPFile()
        Creates an empty FTPFile.
    <!-- ============ METHOD DETAIL ========== -->
    • <!-- -->

      Method Detail

      <!-- -->
      • setRawListing
        public void setRawListing(String rawListing)
        Set the original FTP server raw listing from which the FTPFile was created.
        Parameters:
        rawListing - The raw FTP server listing.
      <!-- -->
      • getRawListing
        public String getRawListing()
        Get the original FTP server raw listing used to initialize the FTPFile.
        Returns:
        The original FTP server raw listing used to initialize the FTPFile.
      <!-- -->
      • isDirectory
        public boolean isDirectory()
        Determine if the file is a directory.
        Returns:
        True if the file is of type DIRECTORY_TYPE, false if not.
      <!-- -->
      • isFile
        public boolean isFile()
        Determine if the file is a regular file.
        Returns:
        True if the file is of type FILE_TYPE, false if not.
      <!-- -->
      • isSymbolicLink
        public boolean isSymbolicLink()
        Determine if the file is a symbolic link.
        Returns:
        True if the file is of type UNKNOWN_TYPE, false if not.
      <!-- -->
      • isUnknown
        public boolean isUnknown()
        Determine if the type of the file is unknown.
        Returns:
        True if the file is of type UNKNOWN_TYPE, false if not.
      <!-- -->
      • isValid
        public boolean isValid()
        Used to indicate whether an entry is valid or not. If the entry is invalid, only the getRawListing() method will be useful. Other methods may fail. Used in conjunction with list parsing that preseverves entries that failed to parse.
        Returns:
        true if the entry is valid
        Since:
        3.4
        See Also:
        FTPClientConfig.setUnparseableEntries(boolean)
      <!-- -->
      • setType
        public void setType(int type)
        Set the type of the file ( DIRECTORY_TYPE, FILE_TYPE, etc.).
        Parameters:
        type - The integer code representing the type of the file.
      <!-- -->
      • getType
        public int getType()
        Return the type of the file (one of the _TYPE constants), e.g., if it is a directory, a regular file, or a symbolic link.
        Returns:
        The type of the file.
      <!-- -->
      • setName
        public void setName(String name)
        Set the name of the file.
        Parameters:
        name - The name of the file.
      <!-- -->
      • getName
        public String getName()
        Return the name of the file.
        Returns:
        The name of the file.
      <!-- -->
      • setSize
        public void setSize(long size)
        Set the file size in bytes.
        Parameters:
        size - The file size in bytes.
      <!-- -->
      • getSize
        public long getSize()
        Return the file size in bytes.
        Returns:
        The file size in bytes.
      <!-- -->
      • setHardLinkCount
        public void setHardLinkCount(int links)
        Set the number of hard links to this file. This is not to be confused with symbolic links.
        Parameters:
        links - The number of hard links to this file.
      <!-- -->
      • getHardLinkCount
        public int getHardLinkCount()
        Return the number of hard links to this file. This is not to be confused with symbolic links.
        Returns:
        The number of hard links to this file.
      <!-- -->
      • setGroup
        public void setGroup(String group)
        Set the name of the group owning the file. This may be a string representation of the group number.
        Parameters:
        group - The name of the group owning the file.
      <!-- -->
      • getGroup
        public String getGroup()
        Returns the name of the group owning the file. Sometimes this will be a string representation of the group number.
        Returns:
        The name of the group owning the file.
      <!-- -->
      • setUser
        public void setUser(String user)
        Set the name of the user owning the file. This may be a string representation of the user number;
        Parameters:
        user - The name of the user owning the file.
      <!-- -->
      • getUser
        public String getUser()
        Returns the name of the user owning the file. Sometimes this will be a string representation of the user number.
        Returns:
        The name of the user owning the file.
      <!-- -->
      • setLink
        public void setLink(String link)
        If the FTPFile is a symbolic link, use this method to set the name of the file being pointed to by the symbolic link.
        Parameters:
        link - The file pointed to by the symbolic link.
      <!-- -->
      • getLink
        public String getLink()
        If the FTPFile is a symbolic link, this method returns the name of the file being pointed to by the symbolic link. Otherwise it returns null.
        Returns:
        The file pointed to by the symbolic link (null if the FTPFile is not a symbolic link).
      <!-- -->
      • setTimestamp
        public void setTimestamp(Calendar date)
        Set the file timestamp. This usually the last modification time. The parameter is not cloned, so do not alter its value after calling this method.
        Parameters:
        date - A Calendar instance representing the file timestamp.
      <!-- -->
      • getTimestamp
        public Calendar getTimestamp()
        Returns the file timestamp. This usually the last modification time.
        Returns:
        A Calendar instance representing the file timestamp.
      <!-- -->
      • setPermission
        public void setPermission(int access,
                         int permission,
                         boolean value)
        Set if the given access group (one of the _ACCESS constants) has the given access permission (one of the _PERMISSION constants) to the file.
        Parameters:
        access - The access group (one of the _ACCESS constants)
        permission - The access permission (one of the _PERMISSION constants)
        value - True if permission is allowed, false if not.
        Throws:
        ArrayIndexOutOfBoundsException - if either of the parameters is out of range
      <!-- -->
      • hasPermission
        public boolean hasPermission(int access,
                            int permission)
        Determines if the given access group (one of the _ACCESS constants) has the given access permission (one of the _PERMISSION constants) to the file.
        Parameters:
        access - The access group (one of the _ACCESS constants)
        permission - The access permission (one of the _PERMISSION constants)
        Returns:
        true if isValid() is true && the associated permission is set; false otherwise.
        Throws:
        ArrayIndexOutOfBoundsException - if either of the parameters is out of range
      <!-- -->
      • toString
        public String toString()
        Returns a string representation of the FTPFile information.
        Overrides:
        toString in class  Object
        Returns:
        A string representation of the FTPFile information.
      <!-- -->
      • toFormattedString
        public String toFormattedString()
        Returns a string representation of the FTPFile information. This currently mimics the Unix listing format. This method uses the timezone of the Calendar entry, which is the server time zone (if one was provided) otherwise it is the local time zone.

        Note: if the instance is not valid isValid(), no useful information can be returned. In this case, use getRawListing() instead.

        Returns:
        A string representation of the FTPFile information.
        Since:
        3.0
      <!-- -->
      • toFormattedString
        public String toFormattedString(String timezone)
        Returns a string representation of the FTPFile information. This currently mimics the Unix listing format. This method allows the Calendar time zone to be overridden.

        Note: if the instance is not valid isValid(), no useful information can be returned. In this case, use getRawListing() instead.

        Parameters:
        timezone - the timezone to use for displaying the time stamp If null, then use the Calendar entry timezone
        Returns:
        A string representation of the FTPFile information.
        Since:
        3.4
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值