public interface FileTransferClient
extends java.io.Closeable
Modifier and Type | Method and Description |
---|---|
void |
chdir(java.lang.String dir)
Change the remote working directory to that supplied
|
default void |
close() |
void |
connect(java.lang.String user,
java.lang.String password)
Connect and login into an account on the FTP server.
|
void |
delete(java.lang.String remoteFile)
Delete the specified remote file
|
default java.lang.String[] |
dir()
List current directory's contents as an array of strings of filenames.
|
default java.lang.String[] |
dir(java.lang.String dirname)
List a directory's contents as an array of strings of filenames.
|
java.lang.String[] |
dir(java.lang.String dirname,
boolean full)
List a directory's contents as an array of strings.
|
java.lang.String[] |
dir(java.lang.String directory,
java.io.FileFilter filter)
List a directory's contents
|
void |
disconnect()
Quit the FTP session
|
void |
get(java.io.OutputStream destStream,
java.lang.String remoteFile)
Get data from the FTP server.
|
byte[] |
get(java.lang.String remoteFile)
Get data from the FTP server.
|
default void |
get(java.lang.String localPath,
java.lang.String remoteFile)
Get data from the FTP server.
|
long |
getKeepAliveTimeout()
Get the time to wait between sending control connection keepalive messages.
|
boolean |
isConnected()
Check if this client is still connected to its target
Any errors return a false
This is used to check cached connections are still working
|
long |
lastModified(java.lang.String path)
Return the last modified time for the given path.
|
java.util.Date |
lastModifiedDate(java.lang.String path)
Return the last modified date for the given path.
|
void |
mkdir(java.lang.String dir)
Create the specified remote working directory
|
default void |
put(byte[] bytes,
java.lang.String remoteFile)
Put data onto the FTP server.
|
default void |
put(byte[] bytes,
java.lang.String remoteFile,
boolean append)
Put data onto the FTP server.
|
default void |
put(java.io.InputStream srcStream,
java.lang.String remoteFile)
Put a stream of data onto the FTP server.
|
void |
put(java.io.InputStream srcStream,
java.lang.String remoteFile,
boolean append)
Put a stream of data onto the FTP server.
|
default void |
put(java.lang.String localPath,
java.lang.String remoteFile)
Put a local file onto the FTP server.
|
default void |
put(java.lang.String localPath,
java.lang.String remoteFile,
boolean append)
Put a local file onto the FTP server.
|
void |
rename(java.lang.String from,
java.lang.String to)
Rename a file or directory
|
void |
rmdir(java.lang.String dir)
Delete the specified remote working directory
|
void |
setAdditionalDebug(boolean b)
Switch additional debug on or off
|
void |
setKeepAliveTimeout(long seconds)
Set the time to wait between sending control connection keepalive messages when processing file upload or download.
|
void connect(java.lang.String user, java.lang.String password) throws java.io.IOException, FileTransferException
user
- user namepassword
- user's passwordFileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occursdefault void put(java.lang.String localPath, java.lang.String remoteFile) throws java.io.IOException, FileTransferException
remoteFile
- name of remote file in current directoryFileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occursput(String, String, boolean)
with append=false
.default void put(java.io.InputStream srcStream, java.lang.String remoteFile) throws java.io.IOException, FileTransferException
srcStream
- input stream of data to putremoteFile
- name of remote fileFileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occursput(String, String, boolean)
with append=false
.default void put(java.lang.String localPath, java.lang.String remoteFile, boolean append) throws java.io.IOException, FileTransferException
localPath
- path of the local fileremoteFile
- name of remote fileappend
- true if appending, false otherwiseFileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occursput(InputStream, String, boolean)
with append=false
.void put(java.io.InputStream srcStream, java.lang.String remoteFile, boolean append) throws java.io.IOException, FileTransferException
srcStream
- input stream of data to putremoteFile
- name of remote fileappend
- true if appending, false otherwiseFileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occursdefault void put(byte[] bytes, java.lang.String remoteFile) throws java.io.IOException, FileTransferException
bytes
- array of bytesremoteFile
- name of remote fileFileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occursput(InputStream, String, boolean)
with append=false
.default void put(byte[] bytes, java.lang.String remoteFile, boolean append) throws java.io.IOException, FileTransferException
bytes
- array of bytesremoteFile
- name of remote fileappend
- true if appending, false otherwiseFileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occursput(InputStream, String, boolean)
.default void get(java.lang.String localPath, java.lang.String remoteFile) throws java.io.IOException, FileTransferException
localPath
- local file to put data inremoteFile
- name of remote fileFileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occursget(OutputStream, String)
.void get(java.io.OutputStream destStream, java.lang.String remoteFile) throws java.io.IOException, FileTransferException
destStream
- data stream to write data toremoteFile
- name of remote fileFileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occursbyte[] get(java.lang.String remoteFile) throws java.io.IOException, FileTransferException
remoteFile
- name of remote fileFileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occursdefault java.lang.String[] dir() throws java.io.IOException, FileTransferException
FileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occursdir(String, boolean)
with dirname=null, full=false
.default java.lang.String[] dir(java.lang.String dirname) throws java.io.IOException, FileTransferException
dirname
- name of directory(not a file mask)FileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occursdir(String, boolean)
with full=false
.java.lang.String[] dir(java.lang.String dirname, boolean full) throws java.io.IOException, FileTransferException
A detailed listing is available, otherwise just filenames are provided. The detailed listing varies in details depending on OS and FTP server. Note that a full listing can be used on a file name to obtain information about a file. The special files "." and ".." are ignored.
dirname
- name of directory (not a file mask)full
- true if detailed listing required false otherwiseFileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occursjava.lang.String[] dir(java.lang.String directory, java.io.FileFilter filter) throws FileTransferException, java.io.IOException
Note that although we use a standard FileFilter
interface here operating on
File
; it actually uses RemoteFile
instead which overrides information
that can be obtained from the remote server. Other standard File
operations will
not be supported, and may ultimately cause a runtime exception.
directory
- the directory to list.filter
- the filefilter mask to usejava.io.IOException
- on comms error.FileTransferException
- on FTP Specific exception error.void delete(java.lang.String remoteFile) throws java.io.IOException, FileTransferException
remoteFile
- name of remote file to deleteFileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occursvoid rename(java.lang.String from, java.lang.String to) throws java.io.IOException, FileTransferException
from
- name of file or directory to renameto
- intended nameFileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occursvoid rmdir(java.lang.String dir) throws java.io.IOException, FileTransferException
dir
- name of remote directory to deleteFileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occursvoid mkdir(java.lang.String dir) throws java.io.IOException, FileTransferException
dir
- name of remote directory to createFileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occursvoid chdir(java.lang.String dir) throws java.io.IOException, FileTransferException
dir
- name of remote directory to change toFileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occursvoid disconnect() throws java.io.IOException, FileTransferException
FileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occurslong lastModified(java.lang.String path) throws java.io.IOException, FileTransferException
path
- the path to the filename.FileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occursjava.util.Date lastModifiedDate(java.lang.String path) throws java.io.IOException, FileTransferException
path
- the path to the filename.FileTransferException
- if an FTP specific exception occursjava.io.IOException
- if a comms error occurslong getKeepAliveTimeout() throws FileTransferException
FileTransferException
void setKeepAliveTimeout(long seconds) throws FileTransferException
seconds
- time in secondsFileTransferException
boolean isConnected()
void setAdditionalDebug(boolean b)
b
- set to true if you wish to get some additional debugging in the log file, defaults to
falsedefault void close() throws java.io.IOException
close
in interface java.lang.AutoCloseable
close
in interface java.io.Closeable
java.io.IOException