URL url = new URL("ftp://ftp.sun.com/pub/test.txt");
UrlConnection con = url.openConnection();
InputStream is = con.getInputStream();
...
is.close();
sun.net.ftp.FtpClient
Modifier and Type | Class and Description |
---|---|
protected static class | FtpURLConnection.
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). |
protected static class | FtpURLConnection.
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). |
Modifier and Type | Field and Description |
---|---|
pack-priv static final int | |
pack-priv static final int | |
private int | |
pack-priv static final int | |
pack-priv String | |
pack-priv FtpClient | |
pack-priv String | |
pack-priv String | |
pack-priv HttpURLConnection | |
private final Proxy | |
pack-priv InputStream | |
pack-priv static final int | |
pack-priv OutputStream | |
pack-priv String | |
pack-priv String | |
pack-priv Permission | |
pack-priv int | |
private int | |
pack-priv int | |
pack-priv String |
Access | Constructor and Description |
---|---|
public | |
pack-priv | FtpURLConnection(URL url, Proxy p)
Same as FtpURLconnection(URL) with a per connection proxy specified |
Modifier and Type | Method and Description |
---|---|
private void | |
private static URL | |
public synchronized void | connect()
Implements abstract java. Connects to the FTP server and logs in. |
private void | |
public int | getConnectTimeout()
Overrides java. Returns setting for connect timeout. |
public InputStream | Returns: theInputStream to the connection.Overrides java. Get the InputStream to retrieve the remote file. |
public OutputStream | Returns: theOutputStream to the connection.Overrides java. Get the OutputStream to store the remote file. |
public Permission | Returns: ThePermission object.Overrides java. Gets the |
public int | |
public String | Returns: the value of the named general request property for this connection.the keyword by which the request is known (e.g., "accept"). key)Overrides sun. Returns the value of the named general request property for this connection. |
pack-priv String | |
public void | setConnectTimeout(int
an timeout)int that specifies the connect
timeout value in millisecondsOverrides java. Sets a specified timeout value, in milliseconds, to be used when opening a communications link to the resource referenced by this URLConnection. |
public void | setReadTimeout(int
an timeout)int that specifies the timeout
value to be used in millisecondsOverrides java. Sets the read timeout to a specified timeout, in milliseconds. |
public void | setRequestProperty(String
the keyword by which the request is known
(e.g., " key, String accept ").the value associated with it. value)Overrides sun. Sets the general request property. |
private void |
ASCII | back to summary |
---|---|
pack-priv static final int ASCII |
BIN | back to summary |
---|---|
pack-priv static final int BIN |
connectTimeout | back to summary |
---|---|
private int connectTimeout |
DIR | back to summary |
---|---|
pack-priv static final int DIR |
filename | back to summary |
---|---|
pack-priv String filename |
ftp | back to summary |
---|---|
pack-priv FtpClient ftp |
fullpath | back to summary |
---|---|
pack-priv String fullpath |
host | back to summary |
---|---|
pack-priv String host |
http | back to summary |
---|---|
pack-priv HttpURLConnection http |
instProxy | back to summary |
---|---|
private final Proxy instProxy |
is | back to summary |
---|---|
pack-priv InputStream is |
NONE | back to summary |
---|---|
pack-priv static final int NONE |
os | back to summary |
---|---|
pack-priv OutputStream os |
password | back to summary |
---|---|
pack-priv String password |
pathname | back to summary |
---|---|
pack-priv String pathname |
permission | back to summary |
---|---|
pack-priv Permission permission |
port | back to summary |
---|---|
pack-priv int port |
readTimeout | back to summary |
---|---|
private int readTimeout |
type | back to summary |
---|---|
pack-priv int type |
user | back to summary |
---|---|
pack-priv String user |
FtpURLConnection | back to summary |
---|---|
public FtpURLConnection(URL url) throws MalformedURLException Creates an FtpURLConnection from a URL.
|
FtpURLConnection | back to summary |
---|---|
pack-priv FtpURLConnection(URL url, Proxy p) throws MalformedURLException Same as FtpURLconnection(URL) with a per connection proxy specified |
cd | back to summary |
---|---|
private void cd(String path) throws FtpProtocolException, IOException |
checkURL | back to summary |
---|---|
private static URL checkURL(URL u) throws MalformedURLException |
connect | back to summary |
---|---|
public synchronized void connect() throws IOException Implements abstract java. Connects to the FTP server and logs in.
|
decodePath | back to summary |
---|---|
private void decodePath(String path) |
getConnectTimeout | back to summary |
---|---|
public int getConnectTimeout() Overrides java. Doc from java. Returns setting for connect timeout. 0 return implies that the option is disabled (i.e., timeout of infinity).
|
getInputStream | back to summary |
---|---|
public InputStream getInputStream() throws IOException Overrides java. Get the InputStream to retrieve the remote file. It will issue the "get" (or "dir") command to the ftp server.
|
getOutputStream | back to summary |
---|---|
public OutputStream getOutputStream() throws IOException Overrides java. Get the OutputStream to store the remote file. It will issue the "put" command to the ftp server.
|
getPermission | back to summary |
---|---|
public Permission getPermission() Overrides java. Gets the
|
getReadTimeout | back to summary |
---|---|
public int getReadTimeout() Overrides java. Doc from java. Returns setting for read timeout. 0 return implies that the option is disabled (i.e., timeout of infinity).
|
getRequestProperty | back to summary |
---|---|
public String getRequestProperty(String key) Overrides sun. Returns the value of the named general request property for this connection.
|
guessContentTypeFromFilename | back to summary |
---|---|
pack-priv String guessContentTypeFromFilename(String fname) |
setConnectTimeout | back to summary |
---|---|
public void setConnectTimeout(int timeout) Overrides java. Doc from java. 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 implementation of this method may ignore the specified timeout. To see the connect timeout set, please call getConnectTimeout().
|
setReadTimeout | back to summary |
---|---|
public void setReadTimeout(int timeout) Overrides java. Doc from java. 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().
|
setRequestProperty | back to summary |
---|---|
public void setRequestProperty(String key, String value) Overrides sun. Sets the general request property. If a property with the key already exists, overwrite its value with the new value.
|
setTimeouts | back to summary |
---|---|
private void setTimeouts() |
Modifier and Type | Field and Description |
---|---|
pack-priv FtpClient |
Access | Constructor and Description |
---|---|
pack-priv |
Modifier and Type | Method and Description |
---|---|
public void | close()
Overrides java. Implements java. Closes this input stream and releases any system resources associated with the stream. |
ftp | back to summary |
---|---|
pack-priv FtpClient ftp |
FtpInputStream | back to summary |
---|---|
pack-priv FtpInputStream(FtpClient cl, InputStream fd) |
close | back to summary |
---|---|
public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this input stream and releases any system resources associated with the stream.
|
Modifier and Type | Field and Description |
---|---|
pack-priv FtpClient |
Access | Constructor and Description |
---|---|
pack-priv |
Modifier and Type | Method and Description |
---|---|
public void | close()
Overrides java. Implements java. Closes this output stream and releases any system resources associated with the stream. |
ftp | back to summary |
---|---|
pack-priv FtpClient ftp |
FtpOutputStream | back to summary |
---|---|
pack-priv FtpOutputStream(FtpClient cl, OutputStream fd) |
close | back to summary |
---|---|
public void close() throws IOException Overrides java. Implements java. Doc from java. Closes this output stream and releases any system resources associated with the stream.
|