public class FtpUtils
extends Object
FTPClient| Constructor and Description |
|---|
FtpUtils()
Instantiates a new FtpUtils.
|
FtpUtils(String proxyHost,
int proxyPort)
Instantiates a new FtpUtils with a socket proxy using provided proxy host
and port.
|
| Modifier and Type | Method and Description |
|---|---|
void |
connect(String urlStr,
String loginId,
String loginPswd,
boolean passiveMode)
Connects to the FTP server.
|
void |
connect(String urlStr,
String loginId,
String loginPswd,
boolean passiveMode,
Properties props)
Connects to the FTP server.
|
boolean |
deleteFile(String folder,
String filename)
Deletes file folder + filename.
|
void |
disconnect()
Disconnects from the FTP server.
|
boolean |
done()
Executed when IO command is finished.
|
void |
executePostLoginCommand()
Execute post login command.
|
List<FileResource> |
getFileList(String folder,
String filename,
boolean includeFolders,
int maxFiles,
String orderBy)
Gets the list of FileResource objects from the folder + filename.
|
org.apache.commons.net.ftp.FTPClient |
getFTPClient()
Gets the FTP client.
|
boolean |
mkDir(String folder)
Creates a folder.
|
boolean |
rename(String fromFolder,
String toFolder,
String filename,
String toFilename)
Renames file fromFolder + filename to toFolder + toFilename.
|
InputStream |
retrieveFile(String pickupFolder,
String filename)
Reads a file pickupFolder + filename and returns it as a InputStream.
|
boolean |
retrieveFile(String pickupFolder,
String filename,
OutputStream out)
Writes a file pickupFolder + filename into OutputStream.
|
boolean |
storeFile(String dropOffFolder,
String filename,
InputStream in)
Stores a file on the server using name dropOffFolder + filename and
taking input from the given InputStream.
|
public FtpUtils()
public FtpUtils(String proxyHost,
int proxyPort)
proxyHost - the socket proxy hostproxyPort - the socket proxy portpublic org.apache.commons.net.ftp.FTPClient getFTPClient()
public void connect(String urlStr,
String loginId,
String loginPswd,
boolean passiveMode)
throws Exception
urlStr - the urlloginId - the login idloginPswd - the login ppasswordpassiveMode - the passive mode flagException - in case of any errorpublic void connect(String urlStr,
String loginId,
String loginPswd,
boolean passiveMode,
Properties props)
throws Exception
urlStr - the urlloginId - the login idloginPswd - the login ppasswordpassiveMode - the passive mode flagprops - the propertiesException - in case of any errorpublic void executePostLoginCommand()
throws Exception
Exception - the exceptionpublic boolean deleteFile(String folder,
String filename)
throws Exception
folder - the folderfilename - the filenameException - in case of any errorpublic void disconnect()
throws Exception
Exception - in case of any errorpublic boolean done()
throws Exception
Exception - in case of any errorpublic List<FileResource> getFileList(String folder, String filename, boolean includeFolders, int maxFiles, String orderBy) throws Exception
folder - the folderfilename - the filenameincludeFolders - the include folders flag. If equals to true recursively
includes sub-foldersmaxFiles - the max filesorderBy - the order byException - in case of any errorFileResourcepublic boolean mkDir(String folder)
throws Exception
folder - the folderException - in case of any errorpublic boolean rename(String fromFolder,
String toFolder,
String filename,
String toFilename)
throws Exception
fromFolder - the from foldertoFolder - the to folderfilename - the filenametoFilename - the to filenameException - in case of any errorpublic InputStream retrieveFile(String pickupFolder,
String filename)
throws Exception
pickupFolder - the pickup folderfilename - the filenameException - in case of any errorpublic boolean retrieveFile(String pickupFolder,
String filename,
OutputStream out)
throws Exception
pickupFolder - the pickup folderfilename - the filenameout - the OutputStreamException - in case of any errorpublic boolean storeFile(String dropOffFolder,
String filename,
InputStream in)
throws Exception
dropOffFolder - the drop off folderfilename - the filenamein - the InputStreamException - in case of any errorCopyright © 2010-2020 Toolsverse. All Rights Reserved.