Package org.apache.commons.net.ftp
Class FTPFile
java.lang.Object
org.apache.commons.net.ftp.FTPFile
- All Implemented Interfaces:
- Serializable
The FTPFile class is used to represent information about files stored on an FTP server.
- See Also:
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final intA constant indicating an FTPFile is a directory.static final intA constant indicating file execute permission or directory listing permission.static final intA constant indicating an FTPFile is a file.static final intA constant indicating group access permissions.static final intA constant indicating file/directory read permission.static final intA constant indicating an FTPFile is a symbolic link.static final intA constant indicating an FTPFile is of unknown type.static final intA constant indicating user access permissions.static final intA constant indicating world access permissions.static final intA constant indicating file/directory write permission.
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptiongetGroup()Gets the name of the group owning the file.intGets the number of hard links to this file.getLink()If the FTPFile is a symbolic link, this method returns the name of the file being pointed to by the symbolic link.getName()Gets the name of the file.Gets the original FTP server raw listing used to initialize the FTPFile.longgetSize()Gets the file size in bytes.Gets the file timestamp.Gets the file timestamp.intgetType()Gets the type of the file (one of the_TYPEconstants), e.g., if it is a directory, a regular file, or a symbolic link.getUser()Gets the name of the user owning the file.booleanhasPermission(int access, int permission) Tests if the given access group (one of the_ACCESSconstants) has the given access permission (one of the_PERMISSIONconstants) to the file.booleanTests if the file is a directory.booleanisFile()Tests if the file is a regular file.booleanTests if the file is a symbolic link.booleanTests if the type of the file is unknown.booleanisValid()Tests whether an entry is valid or not.voidSets the name of the group owning the file.voidsetHardLinkCount(int links) Sets the number of hard links to this file.voidIf the FTPFile is a symbolic link, use this method to set the name of the file being pointed to by the symbolic link.voidSets the name of the file.voidsetPermission(int access, int permission, boolean value) Sets if the given access group (one of the_ACCESSconstants) has the given access permission (one of the_PERMISSIONconstants) to the file.voidsetRawListing(String rawListing) Sets the original FTP server raw listing from which the FTPFile was created.voidsetSize(long size) Sets the file size in bytes.voidsetTimestamp(Calendar date) Sets the file timestamp.voidsetType(int type) Sets the type of the file (DIRECTORY_TYPE,FILE_TYPE, etc.).voidSets the name of the user owning the file.Gets a string representation of the FTPFile information.toFormattedString(String timezone) Gets a string representation of the FTPFile information.toString()Gets a string representation of the FTPFile information.
- 
Field Details- 
FILE_TYPEA constant indicating an FTPFile is a file.- See Also:
 
- 
DIRECTORY_TYPEA constant indicating an FTPFile is a directory.- See Also:
 
- 
SYMBOLIC_LINK_TYPEA constant indicating an FTPFile is a symbolic link.- See Also:
 
- 
UNKNOWN_TYPEA constant indicating an FTPFile is of unknown type.- See Also:
 
- 
USER_ACCESSA constant indicating user access permissions.- See Also:
 
- 
GROUP_ACCESSA constant indicating group access permissions.- See Also:
 
- 
WORLD_ACCESSA constant indicating world access permissions.- See Also:
 
- 
READ_PERMISSIONA constant indicating file/directory read permission.- See Also:
 
- 
WRITE_PERMISSIONA constant indicating file/directory write permission.- See Also:
 
- 
EXECUTE_PERMISSIONA constant indicating file execute permission or directory listing permission.- See Also:
 
 
- 
- 
Constructor Details- 
FTPFilepublic FTPFile()Creates an empty FTPFile.
 
- 
- 
Method Details- 
getGroupGets 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.
 
- 
getHardLinkCountGets 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.
 
- 
getLinkIf the FTPFile is a symbolic link, this method returns the name of the file being pointed to by the symbolic link. Otherwise, it returnsnull.- Returns:
- The file pointed to by the symbolic link (nullif the FTPFile is not a symbolic link).
 
- 
getNameGets the name of the file.- Returns:
- The name of the file.
 
- 
getRawListingGets the original FTP server raw listing used to initialize the FTPFile.- Returns:
- The original FTP server raw listing used to initialize the FTPFile.
 
- 
getSizeGets the file size in bytes.- Returns:
- The file size in bytes.
 
- 
getTimestampGets the file timestamp. This usually the last modification time.- Returns:
- A Calendar instance representing the file timestamp.
 
- 
getTimestampInstantGets the file timestamp. This usually the last modification time.- Returns:
- A Calendar instance representing the file timestamp.
- Since:
- 3.9.0
 
- 
getTypeGets the type of the file (one of the_TYPEconstants), e.g., if it is a directory, a regular file, or a symbolic link.- Returns:
- The type of the file.
 
- 
getUserGets 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.
 
- 
hasPermissionTests if the given access group (one of the_ACCESSconstants) has the given access permission (one of the_PERMISSIONconstants) to the file.- Parameters:
- access- The access group (one of the- _ACCESSconstants)
- permission- The access permission (one of the- _PERMISSIONconstants)
- Returns:
- trueif- isValid()is- trueand the associated permission is set;- falseotherwise.
- Throws:
- ArrayIndexOutOfBoundsException- if either of the parameters is out of range
 
- 
isDirectoryTests if the file is a directory.- Returns:
- trueif the file is of type- DIRECTORY_TYPE,- falseif not.
 
- 
isFileTests if the file is a regular file.- Returns:
- trueif the file is of type- FILE_TYPE,- falseif not.
 
- 
isSymbolicLinkTests if the file is a symbolic link.- Returns:
- trueif the file is of type- SYMBOLIC_LINK_TYPE,- falseif not.
 
- 
isUnknownTests if the type of the file is unknown.- Returns:
- trueif the file is of type- UNKNOWN_TYPE,- falseif not.
 
- 
isValidTests whether an entry is valid or not. If the entry is invalid, only thegetRawListing()method will be useful. Other methods may fail. Used in conjunction with list parsing that preserves entries that failed to parse.- Returns:
- trueif the entry is valid;- falseotherwise
- Since:
- 3.4
- See Also:
 
- 
setGroupSets 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.
 
- 
setHardLinkCountSets 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.
 
- 
setLinkIf 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.
 
- 
setNameSets the name of the file.- Parameters:
- name- The name of the file.
 
- 
setPermissionSets if the given access group (one of the_ACCESSconstants) has the given access permission (one of the_PERMISSIONconstants) to the file.- Parameters:
- access- The access group (one of the- _ACCESSconstants)
- permission- The access permission (one of the- _PERMISSIONconstants)
- value-- trueif permission is allowed,- falseif not.
- Throws:
- ArrayIndexOutOfBoundsException- if either of the parameters is out of range
 
- 
setRawListingSets the original FTP server raw listing from which the FTPFile was created.- Parameters:
- rawListing- The raw FTP server listing.
 
- 
setSizeSets the file size in bytes.- Parameters:
- size- The file size in bytes.
 
- 
setTimestampSets 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.
 
- 
setTypeSets the type of the file (DIRECTORY_TYPE,FILE_TYPE, etc.).- Parameters:
- type- The integer code representing the type of the file.
 
- 
setUserSets 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.
 
- 
toFormattedStringGets a string representation of the FTPFile information. This currently mimics the UNIX listing format. This method uses the time zone 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, usegetRawListing()instead.- Returns:
- A string representation of the FTPFile information.
- Since:
- 3.0
 
- 
toFormattedStringGets 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, usegetRawListing()instead.- Parameters:
- timezone- the time zone to use for displaying the time stamp If- null, then use the Calendar (- getTimestamp()) entry
- Returns:
- A string representation of the FTPFile information.
- Since:
- 3.4
 
- 
toStringGets a string representation of the FTPFile information. Delegates togetRawListing()
 
-