public class FtpClient extends Object
| Modifier and Type | Field and Description |
|---|---|
protected org.slf4j.Logger |
logger |
static int |
TIMEOUT |
| Constructor and Description |
|---|
FtpClient(String server,
int port,
String user,
String password) |
| Modifier and Type | Method and Description |
|---|---|
protected void |
connect()
Initiate a connection to the ftp server
|
boolean |
deleteDir(String dir)
Delete a directory
|
boolean |
deleteFile(String name)
Delete a single file.
|
boolean |
dirExists(String path)
Check if a directory exists by trying to go to it
|
void |
disconnect()
Disconnect the ftp client
|
boolean |
expectFileCount(String directory,
int count,
long timeout)
Verify that a number of files exist on the ftp server
|
boolean |
fileExists(String file)
Check if a file exists on the ftp server
|
String[] |
getFileList(String path)
Get a list of file names in a given directory for admin
|
boolean |
isConnected()
Check if the ftp client is connected
|
boolean |
makeDir(String dir)
Create a directory
|
boolean |
putFile(String fileName,
String targetDir)
Upload a file to the ftp server
|
boolean |
putFile(String fileName,
String targetDir,
String fileContent)
Upload a file to the ftp server
|
void |
recursiveDelete(String path)
Delete all files and subdirectories.
|
boolean |
testConnection() |
protected final transient org.slf4j.Logger logger
public static final int TIMEOUT
public boolean testConnection()
throws IOException
IOExceptionpublic String[] getFileList(String path) throws IOException
IOExceptionpublic boolean makeDir(String dir) throws IOException
dir - IOExceptionpublic boolean deleteDir(String dir) throws IOException
dir - The directory to deleteIOExceptionpublic boolean putFile(String fileName, String targetDir) throws IOException, URISyntaxException
fileName - The file to uploadIOExceptionURISyntaxExceptionpublic boolean putFile(String fileName, String targetDir, String fileContent) throws IOException
fileName - The file to uploadIOExceptionpublic boolean dirExists(String path) throws IOException
path - The directory to tryIOExceptionpublic void recursiveDelete(String path) throws IOException
IOExceptionprotected void connect()
throws IOException
IOExceptionpublic boolean isConnected()
public void disconnect()
throws IOException
IOExceptionpublic boolean fileExists(String file) throws IOException
file - The name of the file to checkIOExceptionpublic boolean deleteFile(String name) throws IOException
name - The file to deleteIOExceptionpublic boolean expectFileCount(String directory, int count, long timeout) throws InterruptedException, IOException
directory - The remote directory to checktimeout - The max time to waitInterruptedExceptionIOExceptionCopyright © 2003–2017 MuleSoft, Inc.. All rights reserved.