|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectcom.myjavaworld.ftp.DataConnection
public class DataConnection
A DataConnection
object is used to transfer data over the data
connection in an FTP process. FTPClient
object will initiate a
DataConnection
based on the commands the send to the remote
host. For more details about data connection, refer to the FTP protocol
specification (RFC 959).
Field Summary | |
---|---|
protected boolean |
abort
A flag for aborting the data transfer. |
protected FTPClient |
client
A reference to the FTPClient that created this
DataConnection . |
protected InputStream |
in
An InputStream object for reading binary data either from the remote host or from the local file system. |
protected EventListenerList |
listenerList
A List of registered listeners that are interested in receiving notifications about the activities of this DataConnection . |
protected OutputStream |
out
An OutputStream object used to write binary data to the remote host or to the local file system. |
protected ServerSocket |
server
A ServerSocket object used in active mode of data transfers. |
protected Socket |
socket
A Socket that represents a data connection. |
Fields inherited from interface com.myjavaworld.ftp.FTPConstants |
---|
DEFAULT_BUFFER_SIZE, DEFAULT_IMPLICIT_SSL_PORT, DEFAULT_MODE, DEFAULT_PORT, DEFAULT_STRUCTURE, DEFAULT_TIMEOUT, DEFAULT_TYPE, EOL, MODE_BLOCK, MODE_COMPRESSED, MODE_STREAM, STRUCTURE_FILE, STRUCTURE_PAGE, STRUCTURE_RECORD, TYPE_ASCII, TYPE_BINARY, TYPE_EBCDIC, TYPE_IMAGE, TYPE_LOCAL, USE_EXPLICIT_SSL, USE_IMPLICIT_SSL, USE_NO_SSL, USE_SSL_IF_AVAILABLE |
Constructor Summary | |
---|---|
DataConnection(FTPClient client)
Constructs a DataConnection object. |
Method Summary | |
---|---|
void |
abort()
Sets the abort flag to true . |
void |
accept()
Listens for connections. |
int |
bind()
Binds a server socket on the local host on a free port. |
void |
close()
Closes this data connection and open streams, if any. |
void |
connect(InetAddress address,
int port)
Connects to the specified InetAddress to the specified port
number. |
void |
connect(String ipAddress,
int port)
Connects to the specified IP address to the specified port number. |
void |
download(File destination,
boolean append)
Reads the stream over this data connection and saves it in the specified local file destination . |
protected void |
fireDataTransferAborted(DataConnectionEvent evt)
Notifies the registered listeners that the data transfer has aborted. |
protected void |
fireDataTransferFinished(DataConnectionEvent evt)
Notifies the registered listeners that the data transfer has finished. |
protected void |
fireDataTransferProgress(DataConnectionEvent evt)
Notifies the registered listeners that the data transfer is in progress. |
protected void |
fireDataTransferStarted(DataConnectionEvent evt)
Notifies the registered listeners that the data transfer has started. |
boolean |
isAborted()
Checks to see if the abort flag was set. |
RemoteFile[] |
list(RemoteFile dir)
Parses the data received over this data connection to an array of RemoteFile objects. |
protected void |
stdout(String message)
Writes the given message to the standard output. |
void |
upload(File source,
long skip)
Sends the contents of the specified local file src to the
remote host. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected FTPClient client
FTPClient
that created this
DataConnection
.
protected ServerSocket server
ServerSocket
object used in active mode of data transfers.
protected Socket socket
protected InputStream in
protected OutputStream out
protected EventListenerList listenerList
DataConnection
.
protected boolean abort
Constructor Detail |
---|
public DataConnection(FTPClient client)
DataConnection
object.
client
- FTPClient
that created this data connection.Method Detail |
---|
public int bind() throws ConnectionException
ConnectionException
- If could not bind a server.public void accept() throws ConnectionException
ConnectionException
- If a network or IO error occurs.public void connect(String ipAddress, int port) throws ConnectionException
ipAddress
- IP address of the remote host in xxx.xxx.xxx.xxx format.port
- Port number to connect to.
ConnectionException
- if a network or IO error occurs.public void connect(InetAddress address, int port) throws ConnectionException
InetAddress
to the specified port
number. This method is called by the FTPClients if they prefer to
transfer data in passive mode.
address
- Internet address of the remote host.port
- Port number to connect to.
ConnectionException
- if a network or IO error occurs.public void close()
public void abort()
true
.
public boolean isAborted()
true
, if the abort request was made.
false
, otherwise.public RemoteFile[] list(RemoteFile dir) throws ConnectionException, ParseException
RemoteFile
objects.
dir
- The remote directory for which the listing is being done.
RemoteFile
objects which are supposedly
the children of the specified directory dir
.
ConnectionException
- If a network or IO error occurs.
ParseException
- if The data can not be parsed to a RemoteFile
object.public void download(File destination, boolean append) throws IOException
destination
.
destination
- The local file to which the contents of the stream are to be
stored.append
- Whether or not to append the contents of the stream to the
local file.
IOException
- if an IO error occurs.public void upload(File source, long skip) throws IOException
src
to the
remote host.
source
- The source for whose contents are to be sent to the remote
host.skip
- If the value of this parameter is greater than zero, these
many bytes will be skipped before sending the data.
IOException
- if an IO error occurs.protected void fireDataTransferStarted(DataConnectionEvent evt)
evt
- DataConnectionEvent
.protected void fireDataTransferFinished(DataConnectionEvent evt)
evt
- DataConnectionEvent
.protected void fireDataTransferAborted(DataConnectionEvent evt)
evt
- DataConnectionEvent
.protected void fireDataTransferProgress(DataConnectionEvent evt)
evt
- DataConnectionEvent
.protected void stdout(String message)
message
- The message to be written.
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |