|
Secure FTP Factory | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.jscape.inet.ftp.Ftp
public class Ftp
Implements the basic functionality of a FTP client.
Example Usage:
// create new Ftp instance Ftp ftp = new Ftp("ftp.myserver.com","anonymous","user@myserver.com"); try { // connect to FTP server ftp.connect(); // print out directory listing System.out.println(ftp.getDirListingAsString()); // disconnect from FTP server ftp.disconnect(); } catch(Exception e) { System.out.println(e); }
Field Summary | |
---|---|
static int |
ASCII
Flag to indicate that ASCII transfer mode is used. |
static int |
AUTO
Flag to indicate that automatic transfer mode detection is used. |
static int |
BINARY
Flag to indicate that BINARY transfer mode is used. |
static java.lang.String |
CURRENT_DIR
Represents the current directory. |
static java.lang.String |
UP_DIR
Represents the parent directory of current directory. |
Constructor Summary | |
---|---|
Ftp()
Creates a new Ftp instance. |
|
Ftp(FtpImplementation impl)
Creates Ftp instance for passed implementation. |
|
Ftp(java.lang.String host,
java.lang.String user,
java.lang.String pwd)
Creates a new Ftp instance. |
|
Ftp(java.lang.String host,
java.lang.String user,
java.lang.String pwd,
java.io.File localDirectory,
FtpImplementation impl)
Creates new Ftp instance. |
|
Ftp(java.lang.String host,
java.lang.String user,
java.lang.String pwd,
FtpImplementation impl)
Creates a new Ftp instance. |
|
Ftp(java.lang.String host,
java.lang.String user,
java.lang.String pwd,
int port,
FtpImplementation impl)
Creates a new Ftp instance. |
Method Summary | |
---|---|
void |
abortDownloadThreads()
Abort all download threads. |
void |
abortUploadThreads()
Cancel all upload threads. |
void |
addFtpListener(FtpListener listener)
Adds FTP event listener. |
void |
changePassword(java.lang.String oldPassword,
java.lang.String newPassword)
Changes password for current account. |
boolean |
checksum(byte[] data,
java.lang.String remoteFile)
Compares checksum of the local data and remote file. |
boolean |
checksum(java.io.File localfile,
java.lang.String remoteFile)
Compares checksum of the local and remote files. |
void |
clearProxySettings()
Clears proxy server values. |
void |
connect()
Connects to FTP server and performs login using specified username, password and optional account. |
void |
connect(boolean login)
Connects to FTP server and optionally performs login. |
void |
deleteDir(java.lang.String remoteDirectory)
Deletes directory from FTP server. |
void |
deleteDir(java.lang.String remoteDirectory,
boolean recurse)
Deletes directory from FTP server. |
void |
deleteFile(java.lang.String remoteFile)
Deletes remote file from FTP server. |
void |
disconnect()
Quits FTP session and disconnects from FTP server. |
void |
download(java.io.OutputStream out,
java.lang.String remoteFile)
Downloads file from FTP server and writes contents to provided OutputStream . |
java.io.File |
download(java.lang.String remoteFile)
Downloads file from FTP server. |
java.io.File |
download(java.lang.String localFile,
java.lang.String remoteFile)
Downloads file from FTP server. |
void |
downloadDir(java.lang.String remoteDir)
Downloads remote directory and contents recursively from FTP server. |
void |
downloadDir(java.lang.String remoteDir,
int retryLimit,
boolean performChecksum)
Downloads remote directory and contents from FTP server. |
void |
downloadDir(java.lang.String remoteDir,
int retryLimit,
boolean performChecksum,
int threadCount)
Download directory. |
void |
downloadDir(java.lang.String remoteDir,
int retryLimit,
int retryInterval,
boolean performChecksum)
Downloads remote directory and contents from FTP server. |
void |
downloadDir(java.lang.String remoteDir,
int retryLimit,
int retryInterval,
boolean performChecksum,
int threadCount)
Downloads remote directory and contents from FTP server. |
java.lang.String |
getAccount()
Gets optional account of FTP server. |
boolean |
getAutoDetectIpv6()
Get auto detect Ipv6 detection mode. |
int |
getBlockTransferSize()
Gets blocksize for use in transferring files. |
java.lang.String |
getCharacterEncoding()
Deprecated. use the getWireEncoding method |
boolean |
getCompression()
Gets whether the data is compressed during the transfering. |
boolean |
getConnectBeforeCommand()
Gets whether passive socket connection should be established before or after sending command to read data from passive connection. |
int |
getDataPort()
Deprecated. replaced by getDataPortStart and getDataPortEnd methods. |
int |
getDataPortEnd()
Gets the data port end range for incoming non-passive (active) data connections. |
int |
getDataPortStart()
Gets the data port start range for incoming non-passive (active) data connections. |
boolean |
getDebug()
Gets debugging state. |
java.io.PrintStream |
getDebugStream()
Gets PrintStream used in reporting debug statements. |
java.lang.String |
getDir()
Gets current working directory of FTP server. |
java.util.Enumeration |
getDirListing()
Gets directory listing from FTP server. |
java.util.Enumeration |
getDirListing(java.lang.String filter)
Gets file listing of files matching filter criteria. |
java.lang.String |
getDirListingAsString()
Gets raw directory listing of files on FTP server. |
java.lang.String |
getDirListingAsString(java.lang.String filter)
Gets raw directory listing of files matching filter criteria. |
java.util.Enumeration |
getDirListingRegex(java.lang.String filter)
Gets directory listing from FTP server returning only file and directory names that match the regular expression. |
boolean |
getErrorOnSizeCommand()
Gets whether an exception should be thrown when downloading a file and server does not support SIZE command. |
java.util.Enumeration |
getFeatures()
Returns supported server features using FEAT command. |
long |
getFilesize(java.lang.String remoteFile)
Gets filesize of remote file from FTP server as represented in ASCII. |
java.util.Date |
getFileTimestamp(java.lang.String remoteFile)
Gets date/timestamp of remote file from FTP server. |
FtpFileParser |
getFtpFileParser()
Gets the FtpFileParser used to parse directory listing returned when
invoking Ftp#getDirListing method. |
java.lang.String |
getHostname()
Gets hostname of FTP server. |
java.io.InputStream |
getInputStream(java.lang.String remoteFile,
long pos)
Gets an InputStream from FTP server for the purposes of downloading a file. |
boolean |
getKeepAlive(boolean keepAlive)
Get socket keep alive. |
int |
getLinger()
Gets the linger time for closing data sockets. |
java.lang.String |
getLocalChecksum(java.io.File localFile)
Returns local checksum. |
java.io.File |
getLocalDir()
Gets local directory to be used in FTP session. |
java.util.Enumeration |
getLocalDirListing()
Gets local directory listing. |
java.util.Enumeration |
getMachineDirListing(java.lang.String dirname)
Gets file listing of specified directory using MLSD command. |
java.util.Enumeration |
getMachineDirListing(java.lang.String dirname,
java.lang.String regex)
Gets file listing of specified directory using MLSD command. |
FtpFile |
getMachineFileListing(java.lang.String filename)
Gets the file description for the specified filename using MLST command. |
int |
getMode()
Gets data transfer mode for current session. |
java.util.Enumeration |
getNameListing()
Gets directory listing of files on FTP server. |
java.util.Enumeration |
getNameListing(java.lang.String filter)
Gets directory listing of files on FTP server matching filter criteria and using NLST command. |
java.lang.String |
getNATAddress()
Get the NAT address. |
java.io.OutputStream |
getOutputStream(java.lang.String fileName,
long off,
boolean append)
Gets an OutputStream from FTP server for the purposes of uploading a file. |
boolean |
getPassive()
Gets whether passive mode should be used. |
java.lang.String |
getPassword()
Returns current FTP user password. |
int |
getPort()
Gets port of FTP server. |
java.lang.String |
getPortAddress()
Gets the external IP address to use when listing for active connections using the PORT command. |
int |
getRecursiveDirectoryFileCount(java.lang.String directory)
Get size of all files rescursively in a given remote directory. |
long |
getRecursiveDirectorySize(java.lang.String directory)
Get size of all files rescursively in a given remote directory. |
java.lang.String |
getRemoteFileChecksum(java.lang.String remoteFile)
Returns remote file checksum. |
java.util.Vector |
getRemoteFileList(java.lang.String remoteDir)
Gets a remote file list fron the current directory. |
int |
getResponseCode()
Gets response code from last FTP command. |
java.lang.String |
getSystemType()
Gets the system type of remote FTP server. |
int |
getTimeout()
Gets the timeout for opening connection to FTP server. |
boolean |
getUseEPRT()
Gets whether to use EPRT or PORT command for data tranfers. |
boolean |
getUseEPSV()
Gets whether to use EPSV or PASV command for data tranfers. |
java.lang.String |
getUsername()
Gets username of FTP user. |
java.lang.String |
getWireEncoding()
Gets encoding set used when issuing commands and transferring files. |
void |
interrupt()
Interrupts the current data transfer and sets interrupted flag to true . |
boolean |
interrupted()
Checks if transfer process was interrupted. |
boolean |
isConnected()
Checks if client is connected to FTP server. |
boolean |
isFeatureSupported(java.lang.String command)
Looks for the command argument into the server features list to validate if it is supported. |
java.lang.String |
issueCommand(java.lang.String cmd)
Issues command to FTP server. |
java.lang.String |
issueCommandCheck(java.lang.String cmd)
Issues command to FTP server. |
void |
login()
Logs into FTP server after establishing a connection. |
void |
makeDir(java.lang.String newDirectory)
Makes directory on FTP server. |
void |
makeDirRecursive(java.lang.String newDirectory)
Makes directory on FTP server, creating subdirectories if necessary. |
java.io.File |
makeLocalDir(java.lang.String directoryName)
Creates local directory. |
void |
mdelete(java.lang.String filter)
Deletes multiple files matching regular expression in FTP server's current directory. |
void |
mdownload(java.util.Enumeration fileNames)
Downloads specified files in current working remote directory from FTP server to local directory. |
void |
mdownload(java.lang.String filter)
Downloads multiple files matching regular expression from FTP server current directory. |
void |
mupload(java.util.Enumeration fileNames)
Uploads multiple files to FTP server. |
void |
mupload(java.lang.String filter)
Uploads multiple files matching regular expression to FTP server's current directory. |
java.lang.String |
noop()
Sends a NOOP (No Operation) command to FTP server. |
void |
readResponse()
Reads server response. |
void |
removeFtpListener(FtpListener listener)
Removes specified FTP event listener. |
void |
renameFile(java.lang.String remoteFile,
java.lang.String newFile)
Renames remote file on FTP server. |
void |
reset()
Resets the interrupted flag to false . |
java.io.File |
resumeDownload(java.lang.String remoteFile,
long off)
Resumes download of file from FTP server. |
java.io.File |
resumeDownload(java.lang.String localFile,
java.lang.String remoteFile,
long off)
Resumes download of file from FTP server. |
void |
resumeUpload(java.io.File localFile,
long off)
Resumes upload of file to FTP server. |
void |
resumeUpload(java.io.File localFile,
java.lang.String remoteFile,
long off)
Resumes upload of file to FTP server. |
void |
resumeUpload(java.lang.String localFile,
long off)
Resumes upload of file to FTP server. |
void |
resumeUpload(java.lang.String localFile,
java.lang.String remoteFile,
long off)
Resumes upload of file to FTP server. |
void |
setAccount(java.lang.String account)
Sets optional account of FTP server. |
void |
setAscii()
Sets data transfer mode to ASCII. |
void |
setAuto(boolean auto)
Sets data transfer mode to be automatically detected. |
void |
setAutoDetectIpv6(boolean value)
Set auto detect Ipv6 detection mode. |
void |
setBinary()
Sets data transfer mode to binary. |
void |
setBlockTransferSize(int blocksize)
Sets block size for use in transferring files. |
void |
setCharacterEncoding(java.lang.String encoding)
Deprecated. use the setWireEncoding method |
void |
setCompression(boolean compression)
Sets whether the data will be compressed during the transfer. |
void |
setConnectBeforeCommand(boolean value)
Sets whether passive socket connection should be established before or after sending command to read data from passive connection. |
void |
setDataPort(int dataPort)
Deprecated. Replaced by setDataPortRange |
void |
setDataPortRange(int dataPortStart,
int dataPortEnd)
Sets the data port range for incoming non-passive (active) connections. |
void |
setDebug(boolean debug)
Sets debugging state. |
void |
setDebugStream(java.io.PrintStream debugStream)
Sets PrintStream used in reporting debug statements. |
void |
setDir(java.lang.String remoteDirectory)
Sets current directory on FTP server. |
void |
setDirUp()
Sets current directory on FTP server to parent directory. |
void |
setErrorOnSizeCommand(boolean error)
Sets whether an exception should be thrown when downloading a file and server does not support SIZE command. |
void |
setFileCreationTime(java.lang.String remoteName,
java.util.Date date)
Sets file creation time with a new value. |
void |
setFileModificationTime(java.lang.String remoteName,
java.util.Date date)
Sets the file modification time with a new value. |
void |
setFileTimestamp(java.lang.String remoteFile,
java.util.Date dateFile)
Sets date/timestamp of remote file on FTP server. |
void |
setFtpFileParser(FtpFileParser parser)
Sets the FtpFileParser used to parse directory listing returned when
invoking Ftp#getDirListing method. |
void |
setHostname(java.lang.String host)
Sets hostname of FTP server. |
void |
setKeepAlive(boolean keepAlive)
Set socket keep alive. |
void |
setLinger(int linger)
Sets the linger time for closing data sockets. |
void |
setLocalDir(java.io.File localDirectory)
Sets local directory to be used in FTP session. |
void |
setNATAddress(java.lang.String ipAddress)
Sets a NAT address which will be used for PASV file transfers. |
void |
setPassive(boolean passive)
Sets whether passive mode should be used. |
void |
setPassword(java.lang.String password)
Sets password of FTP user. |
void |
setPort(int port)
Sets port of FTP server. |
void |
setPortAddress(java.lang.String string)
Sets the external IP address to use when listing for active connections using the PORT command. |
void |
setProxyAuthentication(java.lang.String proxyUsername,
java.lang.String proxyPassword)
Sets the proxy authentication username and password to use with proxy server. |
void |
setProxyHost(java.lang.String proxyHostname,
int proxyPort)
Sets the proxy hostname and port for this FTP connection. |
void |
setProxyType(java.lang.String proxyType)
Sets the proxy type will be used for this FTP connection. |
void |
setReceiveBufferSize(int receiveBufferSize)
Sets the receive buffer size option of the ftp connection. |
void |
setSendBufferSize(int sendBufferSize)
Sets the send buffer size option of the ftp connection. |
void |
setTimeout(int timeout)
Sets the timeout for opening connection to FTP server. |
void |
setUseEPRT(boolean useEPRT)
Sets whether to use EPRT or PASV command for data tranfers. |
void |
setUseEPSV(boolean useEPSV)
Sets whether to use EPSV or PASV command for data tranfers. |
void |
setUsername(java.lang.String user)
Sets username of FTP user. |
void |
setWireEncoding(java.lang.String encoding)
Sets encoding set used when issuing commands and transferring files. |
void |
upload(byte[] data,
java.lang.String remoteFile)
Uploads file to FTP server where contents of file is not on disk but in memory. |
void |
upload(byte[] data,
java.lang.String remoteFile,
boolean append)
Uploads file to FTP server where contents of file is not on disk but in memory. |
void |
upload(java.io.File localFile)
Uploads file to FTP server. |
void |
upload(java.io.File localFile,
boolean append)
Uploads file to FTP server. |
void |
upload(java.io.File localFile,
java.lang.String remoteFile)
Uploads file to FTP server. |
void |
upload(java.io.File localFile,
java.lang.String remoteFile,
boolean append)
Uploads file to FTP server. |
void |
upload(java.io.InputStream input,
java.lang.String remoteFile)
Uploads file to FTP server. |
void |
upload(java.io.InputStream input,
java.lang.String remoteFile,
boolean append)
Uploads file to FTP server. |
void |
upload(java.lang.String localFile)
Uploads file to FTP server. |
void |
upload(java.lang.String localFile,
boolean append)
Uploads file to FTP server. |
void |
upload(java.lang.String extension,
java.io.File localFile)
Uploads file to FTP server and renames the remote file name. |
void |
upload(java.lang.String localFile,
java.lang.String remoteFile)
Uploads file to FTP server. |
void |
upload(java.lang.String localFile,
java.lang.String remoteFile,
boolean append)
Uploads file to FTP server. |
void |
uploadDir(java.io.File localDir)
Uploads local directory and contents recursively to FTP server. |
void |
uploadDir(java.io.File localDir,
int retryLimit,
boolean performChecksum)
Uploads local directory and contents to FTP server. |
void |
uploadDir(java.io.File localDir,
int retryLimit,
boolean performChecksum,
java.lang.String extension,
int threadCount)
|
void |
uploadDir(java.io.File localDir,
int retryLimit,
int retryInterval,
boolean performChecksum,
java.lang.String extension)
Uploads local directory and contents to FTP server. |
void |
uploadDir(java.io.File localDir,
int retryLimit,
int retryInterval,
boolean performChecksum,
java.lang.String extension,
int threadCount)
Uploads local directory and contents to FTP server. |
void |
uploadDir(java.io.File localDir,
java.lang.String extension)
Uploads local directory and contents recursively to FTP server. |
java.lang.String |
uploadUnique(java.io.File file)
Uploads file to FTP server storing remotely using a unique name. |
java.lang.String |
uploadUnique(java.io.File file,
boolean useFilenameAsSeed)
Uploads file to FTP server storing remotely using a unique name. |
java.lang.String |
uploadUnique(java.io.InputStream in,
java.lang.String fileName)
Uploads file to FTP server storing remotely using a unique name. |
java.lang.String |
uploadUnique(java.lang.String fileName)
Uploads file to FTP server storing remotely using a unique name. |
java.lang.String |
uploadUnique(java.lang.String fileName,
boolean useFilenameAsSeed)
Uploads file to FTP server storing remotely using a unique name. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
public static final int AUTO
getMode()
,
Constant Field Valuespublic static final int ASCII
getMode()
,
Constant Field Valuespublic static final int BINARY
getMode()
,
Constant Field Valuespublic static final java.lang.String CURRENT_DIR
public static final java.lang.String UP_DIR
Constructor Detail |
---|
public Ftp(FtpImplementation impl)
impl
- desired implementation.public Ftp()
public Ftp(java.lang.String host, java.lang.String user, java.lang.String pwd, FtpImplementation impl)
host
- the hostname of FTP serveruser
- the username of FTP userpwd
- the password of FTP userimpl
- desired implementation.public Ftp(java.lang.String host, java.lang.String user, java.lang.String pwd, int port, FtpImplementation impl)
host
- the hostname of FTP serveruser
- the username of FTP userpwd
- the password of FTP userport
- the port of FTP serverimpl
- desired implementation.public Ftp(java.lang.String host, java.lang.String user, java.lang.String pwd, java.io.File localDirectory, FtpImplementation impl)
host
- the hostname of FTP serveruser
- the username of FTP userpwd
- the password of FTP userlocalDirectory
- the local directory to be used for uploading
/ downloading filesimpl
- desired implementationpublic Ftp(java.lang.String host, java.lang.String user, java.lang.String pwd)
host
- the hostname of FTP serveruser
- the username of FTP userpwd
- the password of FTP userMethod Detail |
---|
public void setAutoDetectIpv6(boolean value)
value
- public boolean getAutoDetectIpv6()
public void setProxyAuthentication(java.lang.String proxyUsername, java.lang.String proxyPassword)
proxyUsername
- the proxy usernameproxyPassword
- the proxy passwordclearProxySettings()
public void setProxyHost(java.lang.String proxyHostname, int proxyPort)
proxyHostname
- the hostname or ip address of the proxy serverproxyPort
- the port of the proxy server to connect toclearProxySettings()
public void setProxyType(java.lang.String proxyType)
proxyType
- The proxy type. Values allowed: HTTP, SOCKS5public void clearProxySettings()
public void setAscii() throws FtpException
FtpException
- if an I/O or FTP error occurs.public void setAuto(boolean auto)
auto
- true
to turn automatic detect on false
to turn offpublic void setBinary() throws FtpException
FtpException
- if an I/O or FTP error occurs.public void setBlockTransferSize(int blocksize)
blocksize
- the blocksize in bytespublic int getBlockTransferSize()
public void setCharacterEncoding(java.lang.String encoding)
encoding
- the character encoding to be usedpublic java.lang.String getCharacterEncoding()
public void setConnectBeforeCommand(boolean value)
true
.
value
- true
if connection should be established before command, false
otherwisepublic boolean getConnectBeforeCommand()
true
.
true
if connection is established before command, false
otherwisepublic boolean isConnected()
false
will be returned and an FtpConnectionLostEvent
will be fired to any subscribed FtpListener
.
true
if connected false
otherwiseFtpConnectionLostEvent
public void setDataPort(int dataPort)
dataPort
- active portsetDataPortRange(int, int)
public int getDataPort()
getDataPortStart()
,
getDataPortEnd()
public int getDataPortEnd()
public void setDataPortRange(int dataPortStart, int dataPortEnd)
dataPortStart
- start data port range for incoming connectionsdataPortEnd
- end data port range for incoming connectionspublic int getDataPortStart()
public void setDebug(boolean debug)
debug
- true
to turn debugging onsetDebugStream(java.io.PrintStream)
public boolean getDebug()
true
if debugging is onpublic void setDebugStream(java.io.PrintStream debugStream)
debugStream
- the PrintStream to send debug statements toPrintStream
public java.io.PrintStream getDebugStream()
PrintStream
public void setDir(java.lang.String remoteDirectory) throws FtpException
remoteDirectory
- the remote directory
FtpException
- if an I/O or FTP error occurs.public java.lang.String getDir() throws FtpException
FtpException
- if an I/O or FTP error occurs.public java.util.Enumeration getDirListing(java.lang.String filter) throws FtpException
getDirListingRegex
method which uses regular expressions to parse results of a directory listing.
Parsers are included to handle UNIX, NT and VMS directory style listings.
If you are connecting to a FTP server that does not use any of these listing formats
then you can optionally develop your own parser by extending the FtpFileParser
class,
or use some of the alternative methods for obtaining a directory listing such
as the getNameListing
or getDirListingAsString
methods.
filter
- the filename filter to be handled by server
Enumeration
of FtpFile
objects
FtpException
- if an I/O or FTP error occurs.FtpFile
,
getDirListingAsString(String)
,
getDirListingRegex(String)
,
getNameListing(java.lang.String)
,
FtpFileParser
,
UnixParser
,
NTParser
,
VMSParser
public java.util.Enumeration getDirListing() throws FtpException
FtpFileParser
class,
or use some of the alternative methods for obtaining a directory listing such
as the getNameListing
or getDirListingAsString
methods.
Enumeration
of FtpFile
objects
FtpException
- if an I/O or FTP error occurs.FtpFile
,
getDirListingAsString(String)
,
getNameListing(java.lang.String)
,
FtpFileParser
,
UnixParser
,
NTParser
,
VMSParser
public java.lang.String getDirListingAsString(java.lang.String filter) throws FtpException
getDirListingRegex
method which uses regular expressions to parse results of a directory listing.
filter
- the filename filter to be handled by server
String
containing raw directory listing contents
FtpException
- if an I/O or FTP error occurs.getDirListingRegex(String)
public java.lang.String getDirListingAsString() throws FtpException
String
FtpException
- if an I/O or FTP error occurs.public java.util.Enumeration getDirListingRegex(java.lang.String filter) throws FtpException
filter
- regular expression used to obtain the file list
FtpException
- if an I/O or protocol error occurs.public void setDirUp() throws FtpException
FtpException
- if an I/O or FTP error occurs.public void setErrorOnSizeCommand(boolean error)
false
.
error
- true
if exception should be thrown, false
otherwisepublic boolean getErrorOnSizeCommand()
false
.
true
if exception is thrown when SIZE command is not supportedpublic boolean isFeatureSupported(java.lang.String command) throws FtpException
command
- the feature command to search for
true
if the command is found into the server feature list;
false
otherwise
FtpException
- if an I/O or FTP error occurspublic java.util.Enumeration getFeatures() throws FtpException
Enumeration
of features Strings
FtpException
- if an I/O or FTP error occurspublic void setFileTimestamp(java.lang.String remoteFile, java.util.Date dateFile) throws FtpException
remoteFile
- the remote filedateFile
- the date/timestamp of remote file
FtpException
- if an I/O or FTP error occurs.public java.util.Date getFileTimestamp(java.lang.String remoteFile) throws FtpException
remoteFile
- the remote file
FtpException
- if an I/O or FTP error occurs.public void setFileCreationTime(java.lang.String remoteName, java.util.Date date) throws FtpException
remoteName
- the remote file namedate
- the new creation time
FtpException
- If an error occurs.public void setFileModificationTime(java.lang.String remoteName, java.util.Date date) throws FtpException
remoteName
- the remote filedate
- the new modification time
FtpException
- If an error occurspublic long getFilesize(java.lang.String remoteFile) throws FtpException
remoteFile
- the remote file
FtpException
- if an I/O or FTP error occurs.public void setFtpFileParser(FtpFileParser parser)
FtpFileParser
used to parse directory listing returned when
invoking Ftp#getDirListing
method. If FtpFileParser
is null
upon
establishing connection the Ftp
class will attempt to determine the proper
FtpFileParser
based on information retrieved from the FTP server.
If the FtpFileParser
is null
and cannot be determined otherwise then
by default an instance of UnixParser
will be used.
Upon disconnecting from FTP server the FtpFileParser
will be reset to null
.
parser
- a FtpFileParser instanceFtpFileParser
,
UnixParser
,
NTParser
,
VMSParser
public FtpFileParser getFtpFileParser()
FtpFileParser
used to parse directory listing returned when
invoking Ftp#getDirListing
method. If FtpFileParser
is null
upon
establishing connection the Ftp
class will attempt to determine the proper
FtpFileParser
based on information retrieved from the FTP server.
If the FtpFileParser
is null
and cannot be determined otherwise then
by default an instance of UnixParser
will be used.
Upon disconnecting from FTP server the FtpFileParser
will be reset to null
.
FtpFileParser
,
UnixParser
,
NTParser
,
VMSParser
public void setHostname(java.lang.String host)
host
- the hostname or IP address of FTP serverpublic void setAccount(java.lang.String account)
account
- the accountsetUsername(String)
public java.lang.String getAccount()
getUsername()
public java.lang.String getHostname()
public java.io.InputStream getInputStream(java.lang.String remoteFile, long pos) throws FtpException
InputStream
from FTP server for the purposes of downloading a file.
remoteFile
- remote file name to downloadpos
- file offset
FtpException
- if an I/O or FTP error occurs.public void setLinger(int linger)
linger
- the linger value in millisecondspublic int getLinger()
public void setLocalDir(java.io.File localDirectory)
localDirectory
- the local directorypublic java.io.File getLocalDir()
public java.util.Enumeration getLocalDirListing()
Enumeration
of File
public java.util.Enumeration getMachineDirListing(java.lang.String dirname) throws FtpException
dirname
- directory name or empty String
for current directory
Enumeration
of FtpFile
FtpException
- if an I/O or FTP error occursFtpFile
public java.util.Enumeration getMachineDirListing(java.lang.String dirname, java.lang.String regex) throws FtpException
dirname
- directory name or empty String
for current directoryregex
- a regular expression e.g. ".*\\.txt" for all files ending in .txt extension
Enumeration
of FtpFile
FtpException
- if an I/O or FTP error occurspublic FtpFile getMachineFileListing(java.lang.String filename) throws FtpException
filename
- target filename or empty for current directory
FtpFile
FtpException
- if an I/O or FTP error occursFtpFile
public int getMode()
Ftp.AUTO
where 0 = Ftp.AUTO
, 1 = Ftp.ASCII
, 2 = Ftp.BINARY
AUTO
,
BINARY
,
ASCII
public java.util.Enumeration getNameListing(java.lang.String filter) throws FtpException
filter
- the filename filter
Enumeration
of String
where each item represents a file or directory name
FtpException
- if an I/O or FTP related error occurspublic java.util.Enumeration getNameListing() throws FtpException
Enumeration
of String
where each item represents a file or directory name
FtpException
- if an I/O or FTP related error occurspublic java.io.OutputStream getOutputStream(java.lang.String fileName, long off, boolean append) throws FtpException
OutputStream
from FTP server for the purposes of uploading a file.
fileName
- the remote filename to store file asoff
- file offsetappend
- true
to append to remote file on FTP server, false
otherwise
FtpException
- if an FTP error occurs.public void setCompression(boolean compression)
compression
- Compression indicator.public boolean getCompression()
true
data will be compressed, false
otherwise.public void setNATAddress(java.lang.String ipAddress) throws FtpException
setPortAddress
and setDataPortRange
methods.
ipAddress
- The NAT IP address.
FtpException
- if an I/O or FTP error occurssetDataPortRange(int, int)
,
setPortAddress(String)
public java.lang.String getNATAddress()
public void setPassive(boolean passive)
true
.
passive
- true
to use passive transfer, false
otherwisepublic boolean getPassive()
true
.
true
if passive mode is enabled, false
otherwisepublic void setPassword(java.lang.String password)
password
- the password of FTP userpublic java.lang.String getPassword()
public void setPort(int port)
port
- the port of FTP serverpublic int getPort()
public void setPortAddress(java.lang.String string)
string
- an IP addresspublic java.lang.String getPortAddress()
public int getResponseCode()
public java.lang.String getSystemType() throws FtpException
FtpException
- if an I/O or FTP error occurs.public void setSendBufferSize(int sendBufferSize)
sendBufferSize
- Send buffer size.public void setReceiveBufferSize(int receiveBufferSize)
receiveBufferSize
- Receive buffer size.public void setTimeout(int timeout)
timeout
- the timeout in millisecondspublic int getTimeout()
public void setKeepAlive(boolean keepAlive)
keepAlive
- public boolean getKeepAlive(boolean keepAlive)
keepAlive
-
public void setUsername(java.lang.String user)
user
- the username of FTP userpublic void setUseEPSV(boolean useEPSV)
useEPSV
- true
to use EPSV command, false
to use PASV command.public boolean getUseEPRT()
true
to use EPRT command, false
to use PORT command.public void setUseEPRT(boolean useEPRT)
useEPSV
- true
to use EPRT command, false
to use PORT command.public boolean getUseEPSV()
true
to use EPSV command, false
to use PASV command.public java.lang.String getUsername()
public void setWireEncoding(java.lang.String encoding)
encoding
- the character encoding to be usedpublic java.lang.String getWireEncoding()
public void addFtpListener(FtpListener listener)
listener
- the listener to addFtpListener
public void changePassword(java.lang.String oldPassword, java.lang.String newPassword) throws FtpException
oldPassword
- The old password.newPassword
- The new password.
FtpException
- FtpException if underlayed I/O or FTP error occurs.public boolean checksum(java.io.File localfile, java.lang.String remoteFile) throws FtpException
localfile
- local fileremoteFile
- remote file
true
if checksums are equal, false
otherwise
FtpException
- if an error occurspublic boolean checksum(byte[] data, java.lang.String remoteFile) throws FtpException
data
- dataremoteFile
- remote file
true
if checksum are equal, false
otherwise
FtpException
- if an error occurspublic void connect() throws FtpException
FtpException
- if an I/O or FTP error occurs.setUsername(java.lang.String)
,
setPassword(java.lang.String)
,
setAccount(java.lang.String)
public void connect(boolean login) throws FtpException
login
- true
to login false
otherwise
FtpException
- if an I/O or FTP error occurspublic void deleteDir(java.lang.String remoteDirectory, boolean recurse) throws FtpException
recurse
parameter will be used to determine if files and subdirectories within
directory should be removed.
remoteDirectory
- the directory to removerecurse
- true
if it should delete files and subdirectories within directory
FtpException
- if an I/O or FTP error occurs.public void deleteDir(java.lang.String remoteDirectory) throws FtpException
remoteDirectory
- the directory to remove
FtpException
- if an I/O or FTP error occurs.public void deleteFile(java.lang.String remoteFile) throws FtpException
remoteFile
- name of file to delete
FtpException
- if an I/O or FTP error occurs.public void disconnect()
public void download(java.io.OutputStream out, java.lang.String remoteFile) throws FtpException
OutputStream
.
Closure of OutputStream
is responsibility of programmer.
out
- the OutputStream
to write download toremoteFile
- remote filename
FtpException
- if an I/O or FTP error occurspublic java.io.File download(java.lang.String localFile, java.lang.String remoteFile) throws FtpException
localFile
- destination filename relative to current local directory, NOT an absolute pathremoteFile
- remote filename
FtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public java.io.File download(java.lang.String remoteFile) throws FtpException
remoteFile
- the file to download
FtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public void downloadDir(java.lang.String remoteDir) throws FtpException
remoteDir
- the directory to download
FtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public void downloadDir(java.lang.String remoteDir, int retryLimit, boolean performChecksum) throws FtpException
remoteDir
- the directory to downloadretryLimit
- retry limit if an error occursretryInterval
- retry interval in secondsperformChecksum
- whether to perform checksum after each download, not supported by all FTP servers
FtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public void downloadDir(java.lang.String remoteDir, int retryLimit, boolean performChecksum, int threadCount) throws FtpException
remoteDir
- retryLimit
- performChecksum
- threadCount
-
FtpException
public void downloadDir(java.lang.String remoteDir, int retryLimit, int retryInterval, boolean performChecksum, int threadCount) throws FtpException
remoteDir
- the directory to downloadretryLimit
- retry limit if an error occursperformChecksum
- whether to perform checksum after each download, not supported by all FTP servers
FtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public void abortDownloadThreads()
public void downloadDir(java.lang.String remoteDir, int retryLimit, int retryInterval, boolean performChecksum) throws FtpException
remoteDir
- the directory to downloadretryLimit
- retry limit if an error occursperformChecksum
- whether to perform checksum after each download, not supported by all FTP servers
FtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public void interrupt()
true
.
After invoking this method you must reset the interrupted flag to false
before transferring any files.
reset()
public boolean interrupted()
true
if transfer process was interrupted.public java.lang.String issueCommand(java.lang.String cmd) throws FtpException
cmd
- the command to issue
FtpException
- if an I/O or FTP error occurspublic java.lang.String issueCommandCheck(java.lang.String cmd) throws FtpException
cmd
- the command to issue
FtpException
- if an I/O or FTP error occurspublic void login() throws FtpException
Ftp#connect
.
FtpException
- if an I/O or FTP error occurspublic void makeDir(java.lang.String newDirectory) throws FtpException
newDirectory
- name of directory to make
FtpException
- if an I/O or FTP error occurs.public void makeDirRecursive(java.lang.String newDirectory) throws FtpException
newDirectory
- full path of directory to make
FtpException
- if an I/O or FTP error occurspublic java.io.File makeLocalDir(java.lang.String directoryName)
directoryName
- name of directory
getLocalDir()
public void mdelete(java.lang.String filter) throws FtpException
filter
- the filter to use
FtpException
- if an I/O or FTP error occurs.public void mdownload(java.util.Enumeration fileNames) throws FtpException
downloadDir(String)
method.
Downloads are stored relative to current local directory.
fileNames
- filenames of files to download
FtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
,
downloadDir(String)
public void mdownload(java.lang.String filter) throws FtpException
downloadDir
method.
filter
- the regular expression filter to use
FtpException
- if an I/O or FTP error occurssetLocalDir(java.io.File)
,
downloadDir(java.lang.String)
public void mupload(java.util.Enumeration fileNames) throws FtpException
fileNames
- an Enumeration
of String
filenames relative to current local directory to upload
FtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public void mupload(java.lang.String filter) throws FtpException
filter
- the filter to use
FtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public java.lang.String noop() throws FtpException
FtpException
- if an I/O or FTP error occurspublic void readResponse() throws FtpException
FtpException
- if underlayed I/O or FTP error occurs.public void removeFtpListener(FtpListener listener)
listener
- the listener to removeFtpListener
public void renameFile(java.lang.String remoteFile, java.lang.String newFile) throws FtpException
remoteFile
- name of file to renamenewFile
- new name of file
FtpException
- if an I/O or FTP error occurs.public void reset()
false
.
This method should be invoked if you have interrupted a transfer using the
Ftp#interrupt
method and wish to resume transfering files.
interrupt()
public java.io.File resumeDownload(java.lang.String remoteFile, long off) throws FtpException
remoteFile
- the file to downloadoff
- file offset in bytes
FtpException
- if an I/O or FTP error occurs.public java.io.File resumeDownload(java.lang.String localFile, java.lang.String remoteFile, long off) throws FtpException
localFile
- local file nameremoteFile
- the file to downloadoff
- file offset in bytes
FtpException
- if an I/O or FTP error occurs.public void resumeUpload(java.io.File localFile, long off) throws FtpException
localFile
- the local file to uploadoff
- file offset in bytes
FtpException
- if an I/O or FTP error occurs.public void resumeUpload(java.io.File localFile, java.lang.String remoteFile, long off) throws FtpException
localFile
- the local file to uploadremoteFile
- the destination file on FTP serveroff
- local file offset in bytes
FtpException
- if an I/O or FTP error occurspublic void resumeUpload(java.lang.String localFile, long off) throws FtpException
localFile
- the local file to uploadoff
- file offset in bytes
FtpException
- if an I/O or FTP error occurs.public void resumeUpload(java.lang.String localFile, java.lang.String remoteFile, long off) throws FtpException
localFile
- the local file to uploadremoteFile
- the destination file on FTP serveroff
- the local file offset
FtpException
- if an I/O or FTP related error occurs.public void upload(java.io.File localFile, java.lang.String remoteFile, boolean append) throws FtpException
localFile
is a directory then directory and entire contents are uploaded.
localFile
- the local file to uploadremoteFile
- the destination of uploadappend
- true
to append to remote file on FTP server, false
otherwise
FtpException
- if an I/O or FTP related error occurspublic void upload(java.io.InputStream input, java.lang.String remoteFile, boolean append) throws FtpException
input
- the InputStream
to read fromremoteFile
- the destination filename of uploadappend
- true to append, false otherwise
FtpException
- if an I/O or FTP related error occurspublic void upload(java.io.InputStream input, java.lang.String remoteFile) throws FtpException
input
- the InputStream
to read fromremoteFile
- the destination filename of upload
FtpException
- if an I/O or FTP related error occurspublic void upload(java.io.File localFile, boolean append) throws FtpException
localFile
- the local file to uploadappend
- true
to append to remote file on FTP server, false
otherwise
FtpException
- if an I/O or FTP related error occurspublic void upload(java.io.File localFile, java.lang.String remoteFile) throws FtpException
localFile
is a directory then directory and entire contents are uploaded.
localFile
- the local file to uploadremoteFile
- the destination of upload
FtpException
- if an I/O or FTP related error occurspublic void upload(java.io.File localFile) throws FtpException
localFile
is a directory then directory and entire contents are uploaded.
localFile
- the local file to upload
FtpException
- if an I/O or FTP related error occurspublic void upload(java.lang.String extension, java.io.File localFile) throws FtpException
extension
- the temporary extension to append to file before renaminglocalFile
- the local file to upload
FtpException
- if an I/O or FTP related error occurspublic void upload(java.lang.String localFile, java.lang.String remoteFile, boolean append) throws FtpException
localFile
- the local file to uploadremoteFile
- the destination filename of uploadappend
- true
to append to remote file on FTP server, false
otherwise
FtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public void upload(java.lang.String localFile, java.lang.String remoteFile) throws FtpException
localFile
- the local file to uploadremoteFile
- the destination filename of upload
FtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public void upload(java.lang.String localFile, boolean append) throws FtpException
localFile
- the local file to uploadappend
- true
to append to remote file on FTP server, false
otherwise
FtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public void upload(java.lang.String localFile) throws FtpException
localFile
- the local file to upload
FtpException
- if an I/O or FTP error occurs.setLocalDir(java.io.File)
public void upload(byte[] data, java.lang.String remoteFile, boolean append) throws FtpException
data
- the raw contents of the file to uploadremoteFile
- the filename to store file as on FTP serverappend
- true
to append to remote file on FTP server, false
otherwise
FtpException
- if an I/O or FTP related error occurspublic void upload(byte[] data, java.lang.String remoteFile) throws FtpException
data
- the raw contents of the file to uploadremoteFile
- the filename to store file as on FTP server
FtpException
- if an I/O or FTP related error occurspublic void uploadDir(java.io.File localDir) throws FtpException
localDir
- the directory to upload
FtpException
- if an I/O or FTP error occurs.public void uploadDir(java.io.File localDir, java.lang.String extension) throws FtpException
localDir
- the directory to uploadextension
- the temporary extension to use before renaming file or null
to use default extension
FtpException
- if an I/O or FTP error occurs.public void uploadDir(java.io.File localDir, int retryLimit, boolean performChecksum) throws FtpException
localDir
- the directory to uploadretryLimit
- the retry limit if upload failsperformChecksum
- whether to perform checksum after each file upload, not supported by all FTP servers
FtpException
- if an I/O or FTP error occurs.public void uploadDir(java.io.File localDir, int retryLimit, int retryInterval, boolean performChecksum, java.lang.String extension) throws FtpException
localDir
- the directory to uploadretryLimit
- the retry limit if upload failsperformChecksum
- whether to perform checksum after each upload, not supported by all FTP serversextension
- the temporary extension to use before renaming files or null
to use default extension
FtpException
- if an I/O or FTP error occurs.public void uploadDir(java.io.File localDir, int retryLimit, boolean performChecksum, java.lang.String extension, int threadCount) throws FtpException
FtpException
public void uploadDir(java.io.File localDir, int retryLimit, int retryInterval, boolean performChecksum, java.lang.String extension, int threadCount) throws FtpException
localDir
- the directory to uploadretryLimit
- the retry limit if upload failsperformChecksum
- whether to perform checksum after each upload, not supported by all FTP serversextension
- the temporary extension to use before renaming files or null
to use default extensionthreadCount
- the number of threads to use for transferring files
FtpException
- if an I/O or FTP error occurs.public void abortUploadThreads()
public java.lang.String uploadUnique(java.lang.String fileName) throws FtpException
fileName
- the filename to upload, filename will be used as seed for unique remote filename
FtpException
- if an I/O or FTP related error occurspublic java.lang.String uploadUnique(java.lang.String fileName, boolean useFilenameAsSeed) throws FtpException
fileName
- the filename to upload, filename will be used as seed for unique remote filenameuseFilenameAsSeed
- whether filename should be used as seed value for generating unique filename on server
FtpException
- if an I/O or FTP related error occurspublic java.lang.String uploadUnique(java.io.File file) throws FtpException
file
- the file to upload, filename will be used as seed for unique remote filename
FtpException
- if an I/O or FTP related error occurspublic java.lang.String uploadUnique(java.io.File file, boolean useFilenameAsSeed) throws FtpException
file
- the file to upload, filename will be used as seed for unique remote filenameuseFilenameAsSeed
- whether filename should be used as seed value for generating unique filename on server
FtpException
- if an I/O or FTP related error occurspublic java.lang.String uploadUnique(java.io.InputStream in, java.lang.String fileName) throws FtpException
in
- the data InputStream
to upload fromfileName
- the filename to be used as seed for unique remote filename
FtpException
- if an I/O or FTP related error occurspublic int getRecursiveDirectoryFileCount(java.lang.String directory)
directory
- - the remote directory name
public long getRecursiveDirectorySize(java.lang.String directory)
directory
- - the remote directory name
public java.util.Vector getRemoteFileList(java.lang.String remoteDir) throws FtpException
remoteDir
- The current remote directory
FtpException
- If a Ftp error occurspublic java.lang.String getLocalChecksum(java.io.File localFile) throws FtpException
localFile
- the file to use in calculating checksum
FtpException
- if an error occurspublic java.lang.String getRemoteFileChecksum(java.lang.String remoteFile) throws FtpException
remoteFile
- remote file
FtpException
- if an error occurs
|
Secure FTP Factory | |||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |