java.lang.Object | |||
↳ | java.net.URLConnection | ||
↳ | sun.net.www.URLConnection | ||
↳ | sun.net.www.protocol.ftp.FtpURLConnection |
This class Opens an FTP input (or output) stream given a URL. It works as a one shot FTP transfer :
UrlConnection con = url.openConnection();
InputStream is = con.getInputStream();
...
is.close();URL url = new URL("ftp://ftp.sun.com/pub/test.txt");
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
FtpURLConnection.FtpInputStream | For FTP URLs we need to have a special InputStream because we need to close 2 sockets after we're done with it : - The Data socket (for the file). | ||||||||||
FtpURLConnection.FtpOutputStream | For FTP URLs we need to have a special OutputStream because we need to close 2 sockets after we're done with it : - The Data socket (for the file). |
[Expand]
Inherited Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Creates an FtpURLConnection from a URL.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Connects to the FTP server and logs in.
| |||||||||||
Returns setting for connect timeout.
| |||||||||||
Get the InputStream to retreive the remote file.
| |||||||||||
Get the OutputStream to store the remote file.
| |||||||||||
Gets the
Permission associated with the host & port. | |||||||||||
Returns setting for read timeout.
| |||||||||||
Returns the value of the named general request property for this
connection.
| |||||||||||
Sets a specified timeout value, in milliseconds, to be used
when opening a communications link to the resource referenced
by this URLConnection.
| |||||||||||
Sets the read timeout to a specified timeout, in
milliseconds.
| |||||||||||
Sets the general request property.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() |
Creates an FtpURLConnection from a URL.
url | The URL to retrieve or store.
|
---|
Connects to the FTP server and logs in.
if the login is unsuccessful | |
FtpProtocolException | if an error occurs |
UnknownHostException | if trying to connect to an unknown host |
IOException |
Returns setting for connect timeout.
0 return implies that the option is disabled (i.e., timeout of infinity).
int
that indicates the connect timeout
value in millisecondsGet the InputStream to retreive the remote file. It will issue the "get" (or "dir") command to the ftp server.
InputStream
to the connection.IOException | if already opened for output |
---|---|
FtpProtocolException | if errors occur during the transfert. |
Get the OutputStream to store the remote file. It will issue the "put" command to the ftp server.
OutputStream
to the connection.IOException | if already opened for input or the URL points to a directory |
---|---|
FtpProtocolException | if errors occur during the transfert. |
Gets the Permission
associated with the host & port.
Permission
object.
Returns setting for read timeout. 0 return implies that the option is disabled (i.e., timeout of infinity).
int
that indicates the read timeout
value in millisecondsReturns the value of the named general request property for this connection.
key | the keyword by which the request is known (e.g., "accept"). |
---|
IllegalStateException | if already connected |
---|
Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the resource referenced by this URLConnection. If the timeout expires before the connection can be established, a java.net.SocketTimeoutException is raised. A timeout of zero is interpreted as an infinite timeout.
Some non-standard implmentation of this method may ignore the specified timeout. To see the connect timeout set, please call getConnectTimeout().
timeout | an int that specifies the connect
timeout value in milliseconds |
---|
Sets the read timeout to a specified timeout, in milliseconds. A non-zero value specifies the timeout when reading from Input stream when a connection is established to a resource. If the timeout expires before there is data available for read, a java.net.SocketTimeoutException is raised. A timeout of zero is interpreted as an infinite timeout.
Some non-standard implementation of this method ignores the specified timeout. To see the read timeout set, please call getReadTimeout().
timeout | an int that specifies the timeout
value to be used in milliseconds |
---|
Sets the general request property. If a property with the key already exists, overwrite its value with the new value.
key | the keyword by which the request is known
(e.g., "accept "). |
---|---|
value | the value associated with it. |
IllegalStateException | if already connected |
---|