public interface FtpClient
Modifier and Type | Method and Description |
---|---|
boolean |
abort()
Aborts the current operation.
|
OutputStream |
appendFileStream(String relPath)
Returns an OutputStream through which data can be written to append to a file on the server with the given name.
|
boolean |
completePendingCommand()
There are a few FTPClient methods that do not complete the entire sequence of FTP commands to complete a transaction.
|
boolean |
deleteFile(String relPath)
Deletes a file on the FTP server.
|
void |
disconnect()
Sends the FTP QUIT command to the server, receive the reply, and return the reply code.
|
default int |
getReplyCode()
Gets the integer value of the reply code of the last FTP reply.
|
String |
getReplyString()
Gets the entire text of the last FTP server response exactly as it was received, including all end of line markers in
NETASCII format.
|
boolean |
hasFeature(String feature)
Queries the server for a supported feature.
|
boolean |
isConnected()
Tests if the client is currently connected to a server.
|
org.apache.commons.net.ftp.FTPFile[] |
listFiles(String relPath)
Using the default system autodetect mechanism, obtain a list of file information for the current working directory or
for just a single file.
|
boolean |
makeDirectory(String relPath)
Creates a new subdirectory on the FTP server in the current directory (if a relative pathname is given) or where
specified (if an absolute pathname is given).
|
default Instant |
mdtmInstant(String relPath)
Sends the MDTM command to get a file's date and time information after file transfer.
|
boolean |
removeDirectory(String relPath)
Removes a directory on the FTP server (if empty).
|
boolean |
rename(String from,
String to)
Renames a remote file.
|
InputStream |
retrieveFileStream(String relPath)
Returns an InputStream from which a named file from the server can be read.
|
default InputStream |
retrieveFileStream(String relPath,
int bufferSize)
Returns an InputStream from which a named file from the server can be read.
|
InputStream |
retrieveFileStream(String relPath,
long restartOffset)
Returns an InputStream from which a named file from the server can be read.
|
default void |
setBufferSize(int bufferSize)
Sets the buffer size for buffered data streams.
|
OutputStream |
storeFileStream(String relPath)
Returns an OutputStream through which data can be written to store a file on the server using the given name.
|
boolean abort() throws IOException
IOException
- If an I/O error occursOutputStream appendFileStream(String relPath) throws IOException
relPath
- The name of the remote file.IOException
- If an I/O error occurs.boolean completePendingCommand() throws IOException
IOException
- If an I/O error occurs.boolean deleteFile(String relPath) throws IOException
relPath
- The relPath of the file to be deleted.IOException
- If an I/O error occurs.void disconnect() throws IOException
IOException
- If an I/O error occurs.default int getReplyCode() throws IOException
IOException
- If an I/O error occurs.String getReplyString() throws IOException
IOException
- If an I/O error occurs.boolean hasFeature(String feature) throws IOException
feature
- the name of the feature, converted to upper case.true
if the feature is present, false
if the feature is not present or the FTP command
failed.IOException
- If an I/O error occurs.boolean isConnected() throws FileSystemException
FileSystemException
- If an I/O error occurs.org.apache.commons.net.ftp.FTPFile[] listFiles(String relPath) throws IOException
TODO This interface should not leak Apache Commons NET types like FTPFile
relPath
- The file or directory to list.IOException
- If an I/O error occurs.boolean makeDirectory(String relPath) throws IOException
relPath
- The pathname of the directory to create.IOException
- If an I/O error occurs.default Instant mdtmInstant(String relPath) throws IOException
"LIST"
command response. Time values are always represented in UTC (GMT), and in the Gregorian
calendar regardless of what calendar may have been in use at the date and time the file was last modified.
NOTE: not all remote FTP servers support MDTM
.
relPath
- The relative path of the file object to execute MDTM
command againstInstant
object containing the MDTM
timestamp.IOException
- If an I/O error occurs.boolean removeDirectory(String relPath) throws IOException
relPath
- The pathname of the directory to remove.IOException
- If an I/O error occurs.boolean rename(String from, String to) throws IOException
from
- The name of the remote file to rename.to
- The new name of the remote file.IOException
- If an I/O error occurs.InputStream retrieveFileStream(String relPath) throws IOException
relPath
- The name of the remote file.IOException
- If an I/O error occurs.default InputStream retrieveFileStream(String relPath, int bufferSize) throws IOException
relPath
- The name of the remote file.bufferSize
- buffer size.IOException
- If an I/O error occurs.InputStream retrieveFileStream(String relPath, long restartOffset) throws IOException
relPath
- The name of the remote file.restartOffset
- restart offset.IOException
- If an I/O error occurs.default void setBufferSize(int bufferSize) throws FileSystemException
bufferSize
- The size of the buffer.FileSystemException
- If an I/O error occurs.OutputStream storeFileStream(String relPath) throws IOException
relPath
- The name to give the remote file.IOException
- If an I/O error occurs.Copyright © 2002–2025 The Apache Software Foundation. All rights reserved.