Top Fields Constructors Methods
sun.net.www.protocol.file

public Class FileURLConnection

extends URLConnection
Class Inheritance
Imports
java.net.URL, .FileNameMap, java.io.*, java.text.Collator, .SimpleDateFormat, java.security.Permission, sun.net.www.*, java.util.*

Field Summary

Modifier and TypeField and Description
private static final String
private static final String
pack-priv String
pack-priv boolean
pack-priv File
pack-priv String
pack-priv List<String>
private boolean
pack-priv InputStream
pack-priv boolean
private static final String
pack-priv long
pack-priv long
pack-priv Permission
private static final String
Inherited from sun.net.www.URLConnection:
properties

Constructor Summary

AccessConstructor and Description
protected

Method Summary

Modifier and TypeMethod and Description
public synchronized void
public void
connect()

Implements abstract java.net.URLConnection.connect.

Opens a communications link to the resource referenced by this URL, if such a connection has not already been established.
public int
getContentLength()

Overrides sun.net.www.URLConnection.getContentLength.

Call this routine to get the content-length associated with this object.
public long
getContentLengthLong()

Overrides java.net.URLConnection.getContentLengthLong.

Returns the value of the content-length header field as a long.
public String
getHeaderField(String
the name of a header field.
name
)

Overrides sun.net.www.URLConnection.getHeaderField.

Returns the value of the named header field.
public String
getHeaderField(int
an index, where n>=0
n
)

Overrides sun.net.www.URLConnection.getHeaderField.

Return the value for the nth header field.
public String
getHeaderFieldKey(int
an index, where n>=0
n
)

Overrides sun.net.www.URLConnection.getHeaderFieldKey.

Return the key for the nth header field.
public Map<String, List<String>>
getHeaderFields()

Overrides sun.net.www.URLConnection.getHeaderFields.

Returns an unmodifiable Map of the header fields.
public synchronized InputStream
getInputStream()

Overrides java.net.URLConnection.getInputStream.

Returns an input stream that reads from this open connection.
public long
getLastModified()

Overrides java.net.URLConnection.getLastModified.

Returns the value of the last-modified header field.
public Permission
getPermission()

Overrides java.net.URLConnection.getPermission.

Returns a permission object representing the permission necessary to make the connection represented by this object.
public MessageHeader
getProperties()

Overrides sun.net.www.URLConnection.getProperties.

Call this routine to get the property list for this object.
private void
Inherited from sun.net.www.URLConnection:
addRequestPropertycanCacheclosegetContentTypegetRequestPropertiesgetRequestPropertyisProxiedHostsetContentLengthsetContentTypesetPropertiessetProxiedHostsetRequestProperty

Field Detail

CONTENT_LENGTHback to summary
private static final String CONTENT_LENGTH
CONTENT_TYPEback to summary
private static final String CONTENT_TYPE
contentTypeback to summary
pack-priv String contentType

Hides sun.net.www.URLConnection.contentType.

existsback to summary
pack-priv boolean exists
fileback to summary
pack-priv File file
filenameback to summary
pack-priv String filename
filesback to summary
pack-priv List<String> files
initializedHeadersback to summary
private boolean initializedHeaders
isback to summary
pack-priv InputStream is
isDirectoryback to summary
pack-priv boolean isDirectory
LAST_MODIFIEDback to summary
private static final String LAST_MODIFIED
lastModifiedback to summary
pack-priv long lastModified
lengthback to summary
pack-priv long length
permissionback to summary
pack-priv Permission permission
TEXT_PLAINback to summary
private static final String TEXT_PLAIN

Constructor Detail

FileURLConnectionback to summary
protected FileURLConnection(URL u, File file)

Method Detail

closeInputStreamback to summary
public synchronized void closeInputStream() throws IOException
connectback to summary
public void connect() throws IOException

Implements abstract java.net.URLConnection.connect.

Doc from java.net.URLConnection.connect.

Opens a communications link to the resource referenced by this URL, if such a connection has not already been established.

If the connect method is called when the connection has already been opened (indicated by the connected field having the value true), the call is ignored.

URLConnection objects go through two phases: first they are created, then they are connected. After being created, and before being connected, various options can be specified (e.g., doInput and UseCaches). After connecting, it is an error to try to set them. Operations that depend on being connected, like getContentLength, will implicitly perform the connection, if necessary.

Exceptions
IOException:
if an I/O error occurs while opening the connection.
getContentLengthback to summary
public int getContentLength()

Overrides sun.net.www.URLConnection.getContentLength.

Doc from sun.net.www.URLConnection.getContentLength.

Call this routine to get the content-length associated with this object.

Returns:int

Doc from java.net.URLConnection.getContentLength.

the content length of the resource that this connection's URL references, -1 if the content length is not known, or if the content length is greater than Integer.MAX_VALUE.

getContentLengthLongback to summary
public long getContentLengthLong()

Overrides java.net.URLConnection.getContentLengthLong.

Doc from java.net.URLConnection.getContentLengthLong.

Returns the value of the content-length header field as a long.

Returns:long

the content length of the resource that this connection's URL references, or -1 if the content length is not known.

getHeaderFieldback to summary
public String getHeaderField(String name)

Overrides sun.net.www.URLConnection.getHeaderField.

Doc from java.net.URLConnection.getHeaderField.

Returns the value of the named header field.

If called on a connection that sets the same header multiple times with possibly different values, only the last value is returned.

Parameters
name:String

the name of a header field.

Returns:String

the value of the named header field, or null if there is no such field in the header.

getHeaderFieldback to summary
public String getHeaderField(int n)

Overrides sun.net.www.URLConnection.getHeaderField.

Doc from sun.net.www.URLConnection.getHeaderField.

Return the value for the nth header field. Returns null if there are fewer than n fields. This can be used in conjunction with getHeaderFieldKey to iterate through all the headers in the message.

Parameters
n:int

Doc from java.net.URLConnection.getHeaderField.

an index, where n>=0

Returns:String

Doc from java.net.URLConnection.getHeaderField.

the value of the nth header field or null if there are fewer than n+1 fields

getHeaderFieldKeyback to summary
public String getHeaderFieldKey(int n)

Overrides sun.net.www.URLConnection.getHeaderFieldKey.

Doc from sun.net.www.URLConnection.getHeaderFieldKey.

Return the key for the nth header field. Returns null if there are fewer than n fields. This can be used to iterate through all the headers in the message.

Parameters
n:int

Doc from java.net.URLConnection.getHeaderFieldKey.

an index, where n>=0

Returns:String

Doc from java.net.URLConnection.getHeaderFieldKey.

the key for the nth header field, or null if there are fewer than n+1 fields when n > 0.

getHeaderFieldsback to summary
public Map<String, List<String>> getHeaderFields()

Overrides sun.net.www.URLConnection.getHeaderFields.

Doc from java.net.URLConnection.getHeaderFields.

Returns an unmodifiable Map of the header fields. The Map keys are Strings that represent the response-header field names. Each Map value is an unmodifiable List of Strings that represents the corresponding field values. This method is overridden by the subclasses of URLConnection. In the implementation of these methods, if a given key has multiple corresponding values, they must be returned in the order they were added, preserving the insertion-order.

Returns:Map<String, List<String>>

a Map of header fields

getInputStreamback to summary
public synchronized InputStream getInputStream() throws IOException

Overrides java.net.URLConnection.getInputStream.

Doc from java.net.URLConnection.getInputStream.

Returns an input stream that reads from this open connection. A SocketTimeoutException can be thrown when reading from the returned input stream if the read timeout expires before data is available for read.

Returns:InputStream

an input stream that reads from this open connection.

Exceptions
IOException:
if an I/O error occurs while creating the input stream.
getLastModifiedback to summary
public long getLastModified()

Overrides java.net.URLConnection.getLastModified.

Doc from java.net.URLConnection.getLastModified.

Returns the value of the last-modified header field. The result is the number of milliseconds since January 1, 1970 GMT.

Returns:long

the date the resource referenced by this URLConnection was last modified, or 0 if not known.

getPermissionback to summary
public Permission getPermission() throws IOException

Overrides java.net.URLConnection.getPermission.

Doc from java.net.URLConnection.getPermission.

Returns a permission object representing the permission necessary to make the connection represented by this object. This method returns null if no permission is required to make the connection. By default, this method returns java.security.AllPermission. Subclasses should override this method and return the permission that best represents the permission required to make a connection to the URL. For example, a URLConnection representing a file: URL would return a java.io.FilePermission object.

The permission returned may dependent upon the state of the connection. For example, the permission before connecting may be different from that after connecting. For example, an HTTP sever, say foo.com, may redirect the connection to a different host, say bar.com. Before connecting the permission returned by the connection will represent the permission needed to connect to foo.com, while the permission returned after connecting will be to bar.com.

Permissions are generally used for two purposes: to protect caches of objects obtained through URLConnections, and to check the right of a recipient to learn about a particular URL. In the first case, the permission should be obtained after the object has been obtained. For example, in an HTTP connection, this will represent the permission to connect to the host from which the data was ultimately fetched. In the second case, the permission should be obtained and tested before connecting.

Returns:Permission

the permission object representing the permission necessary to make the connection represented by this URLConnection.

Exceptions
IOException:
if the computation of the permission requires network or file I/O and an exception occurs while computing it.
getPropertiesback to summary
public MessageHeader getProperties()

Overrides sun.net.www.URLConnection.getProperties.

Doc from sun.net.www.URLConnection.getProperties.

Call this routine to get the property list for this object. Properties (like content-type) that have explicit getXX() methods associated with them should be accessed using those methods.

initializeHeadersback to summary
private void initializeHeaders()