Class FTPConnection
java.lang.Object
org.deltava.util.ftp.FTPConnection
- All Implemented Interfaces:
Closeable
,AutoCloseable
-
Nested Class Summary
Nested Classes -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
void
Connects and logs into the remote server.Downloads a file from the remote server.Downloads a file from the remote server into a specified location.com.enterprisedt.net.ftp.FTPClient
Returns the underlying FTP client object.getNewest
(String dirName, FilenameFilter filter) Returns the name of the newest file on the FTP server.getNewestDirectory
(String dirName, FilenameFilter filter) Returns the name of the newest directory on the FTP server.getTimestamp
(String dirName, String fName) Returns the last modified date for a particular file on the remote server.boolean
Returns whether a particular file exists on the remote server.boolean
Returns if connected to the remote server.void
Uploads a file to the remote server.
-
Constructor Details
-
FTPConnection
Creates a new FTP connection object.- Parameters:
host
- the remote host name
-
-
Method Details
-
getClient
public com.enterprisedt.net.ftp.FTPClient getClient()Returns the underlying FTP client object.- Returns:
- the client object
-
isConnected
public boolean isConnected()Returns if connected to the remote server.- Returns:
- TRUE if connected to the server, otherwise FALSE
-
connect
Connects and logs into the remote server.- Parameters:
user
- the user IDpwd
- the password- Throws:
FTPClientException
- if a connection error occurs
-
close
public void close()- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
-
get
Downloads a file from the remote server.- Parameters:
fName
- the remote file namesaveToDisk
- TRUE if the file should be saved to a temporary file, otherwise FALSE- Returns:
- an InputStream pointing to the file data
- Throws:
FTPClientException
- if an error occurs
-
get
Downloads a file from the remote server into a specified location.- Parameters:
fName
- the remote file namedestFile
- the destination location- Returns:
- an InputStream pointing to the file data
- Throws:
FTPClientException
- if an error occurs
-
put
Uploads a file to the remote server.- Parameters:
f
- the local File- Throws:
FTPClientException
- if an error occurs
-
hasFile
Returns whether a particular file exists on the remote server.- Parameters:
dirName
- the remote directory namefName
- the remote file name- Returns:
- TRUE if the file exists, otherwise FALSE
- Throws:
FTPClientException
- if an error occurs
-
getTimestamp
Returns the last modified date for a particular file on the remote server.- Parameters:
dirName
- the remote directory namefName
- the remote file name- Returns:
- the last modified date/time, or null if the file does not exist on the remote server
- Throws:
FTPClientException
- if an error occurs
-
getNewestDirectory
Returns the name of the newest directory on the FTP server.- Parameters:
dirName
- the directory namefilter
- a FilenameFilter, or null if none- Returns:
- the file name, or null if not found
- Throws:
FTPClientException
- if an error occurs
-
getNewest
Returns the name of the newest file on the FTP server.- Parameters:
dirName
- the directory namefilter
- a FilenameFilter, or null if none- Returns:
- the file name, or null if not found
- Throws:
FTPClientException
- if an error occurs
-