public class FtpClient extends Object
Modifier and Type | Field and Description |
---|---|
protected Log |
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 Log logger
public static final int TIMEOUT
public boolean testConnection() throws IOException
IOException
public String[] getFileList(String path) throws IOException
IOException
public boolean makeDir(String dir) throws IOException
dir
- IOException
public boolean deleteDir(String dir) throws IOException
dir
- The directory to deleteIOException
public boolean putFile(String fileName, String targetDir) throws IOException
fileName
- The file to uploadIOException
public boolean putFile(String fileName, String targetDir, String fileContent) throws IOException
fileName
- The file to uploadIOException
public boolean dirExists(String path) throws IOException
path
- The directory to tryIOException
public void recursiveDelete(String path) throws IOException
IOException
protected void connect() throws IOException
IOException
public boolean isConnected()
public void disconnect() throws IOException
IOException
public boolean fileExists(String file) throws IOException
file
- The name of the file to checkIOException
public boolean deleteFile(String name) throws IOException
name
- The file to deleteIOException
public boolean expectFileCount(String directory, int count, long timeout) throws InterruptedException, IOException
directory
- The remote directory to checktimeout
- The max time to waitInterruptedException
IOException
Copyright © 2003–2016 MuleSoft, Inc.. All rights reserved.