public class FTPFile extends Object implements Serializable
FTPFileEntryParser
,
FTPClient.listFiles()
,
Serialized FormModifier and Type | Field 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 and Description |
---|
FTPFile()
Creates an empty FTPFile.
|
Modifier and Type | Method and Description |
---|---|
String |
getGroup()
Gets the name of the group owning the file.
|
int |
getHardLinkCount()
Gets 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()
Gets the name of the file.
|
String |
getRawListing()
Gets the original FTP server raw listing used to initialize the FTPFile.
|
long |
getSize()
Gets the file size in bytes.
|
Calendar |
getTimestamp()
Gets the file timestamp.
|
int |
getType()
Gets 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()
Gets the name of the user owning the file.
|
boolean |
hasPermission(int access,
int permission)
Tests 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()
Tests if the file is a directory.
|
boolean |
isFile()
Tests if the file is a regular file.
|
boolean |
isSymbolicLink()
Tests if the file is a symbolic link.
|
boolean |
isUnknown()
Tests if the type of the file is unknown.
|
boolean |
isValid()
Tests whether an entry is valid or not.
|
void |
setGroup(String group)
Sets the name of the group owning the file.
|
void |
setHardLinkCount(int links)
Sets 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)
Sets the name of the file.
|
void |
setPermission(int access,
int permission,
boolean value)
Sets 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)
Sets the original FTP server raw listing from which the FTPFile was created.
|
void |
setSize(long size)
Sets the file size in bytes.
|
void |
setTimestamp(Calendar date)
Sets the file timestamp.
|
void |
setType(int type)
Sets the type of the file (
DIRECTORY_TYPE , FILE_TYPE , etc.). |
void |
setUser(String user)
Sets the name of the user owning the file.
|
String |
toFormattedString()
Gets a string representation of the FTPFile information.
|
String |
toFormattedString(String timezone)
Gets a string representation of the FTPFile information.
|
String |
toString()
Gets a string representation of the FTPFile information.
|
public static final int FILE_TYPE
public static final int DIRECTORY_TYPE
public static final int SYMBOLIC_LINK_TYPE
public static final int UNKNOWN_TYPE
public static final int USER_ACCESS
public static final int GROUP_ACCESS
public static final int WORLD_ACCESS
public static final int READ_PERMISSION
public static final int WRITE_PERMISSION
public static final int EXECUTE_PERMISSION
public String getGroup()
public int getHardLinkCount()
public String getLink()
public String getName()
public String getRawListing()
public long getSize()
public Calendar getTimestamp()
public int getType()
_TYPE
constants), e.g., if it is a directory, a regular
file, or a symbolic link.public String getUser()
public boolean hasPermission(int access, int permission)
_ACCESS
constants) has the given access
permission (one of the _PERMISSION
constants) to the file.access
- The access group (one of the _ACCESS
constants)permission
- The access permission (one of the _PERMISSION
constants)isValid()
is true &&
the associated permission is set; false
otherwise.ArrayIndexOutOfBoundsException
- if either of the parameters is out of rangepublic boolean isDirectory()
DIRECTORY_TYPE
, false if not.public boolean isFile()
FILE_TYPE
, false if not.public boolean isSymbolicLink()
UNKNOWN_TYPE
, false if not.public boolean isUnknown()
UNKNOWN_TYPE
, false if not.public boolean isValid()
getRawListing()
method will be useful. Other methods may fail.
Used in conjunction with list parsing that preseverves entries that failed to parse.FTPClientConfig.setUnparseableEntries(boolean)
public void setGroup(String group)
group
- The name of the group owning the file.public void setHardLinkCount(int links)
links
- The number of hard links to this file.public void setLink(String link)
link
- The file pointed to by the symbolic link.public void setName(String name)
name
- The name of the file.public void setPermission(int access, int permission, boolean value)
_ACCESS
constants) has the given access permission (one
of the _PERMISSION
constants) to the file.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.ArrayIndexOutOfBoundsException
- if either of the parameters is out of rangepublic void setRawListing(String rawListing)
rawListing
- The raw FTP server listing.public void setSize(long size)
size
- The file size in bytes.public void setTimestamp(Calendar date)
date
- A Calendar instance representing the file timestamp.public void setType(int type)
DIRECTORY_TYPE
, FILE_TYPE
, etc.).type
- The integer code representing the type of the file.public void setUser(String user)
user
- The name of the user owning the file.public String toFormattedString()
Note: if the instance is not valid isValid()
, no useful information can be returned. In this case, use
getRawListing()
instead.
public String toFormattedString(String timezone)
Note: if the instance is not valid isValid()
, no useful information can be returned. In this case, use
getRawListing()
instead.
timezone
- the time zone to use for displaying the time stamp If null
, then use the Calendar entryCopyright © 2001–2021 The Apache Software Foundation. All rights reserved.