Package libcore.net.url
Class FileURLConnection
java.lang.Object
java.net.URLConnection
libcore.net.url.FileURLConnection
public class FileURLConnection extends URLConnection
This subclass extends
URLConnection.
This class is responsible for connecting, getting content and input stream of the file.
-
Field Summary
Fields inherited from class java.net.URLConnection
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches -
Constructor Summary
Constructors Constructor Description FileURLConnection(URL url)Creates an instance ofFileURLConnectionfor establishing a connection to the file pointed by thisURL -
Method Summary
Modifier and Type Method Description voidconnect()This methods will attempt to obtain the input stream of the file pointed by thisURL.intgetContentLength()Returns the length of the file in bytes.StringgetContentType()Returns the content type of the resource.InputStreamgetInputStream()Returns the input stream of the object referred to by thisURLConnectionFile Sample : "/ZIP211/+/harmony/tools/javac/resources/javac.properties" Invalid File Sample: "/ZIP/+/harmony/tools/javac/resources/javac.properties" "ZIP211/+/harmony/tools/javac/resources/javac.properties"PermissiongetPermission()Returns the permission, in this case the subclass, FilePermission object which represents the permission necessary for this URLConnection to establish the connection.Methods inherited from class java.net.URLConnection
addRequestProperty, getAllowUserInteraction, getConnectTimeout, getContent, getContent, getContentEncoding, getDate, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderField, getHeaderField, getHeaderFieldDate, getHeaderFieldInt, getHeaderFieldKey, getHeaderFields, getIfModifiedSince, getLastModified, getOutputStream, getReadTimeout, getRequestProperties, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setConnectTimeout, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setReadTimeout, setRequestProperty, setUseCaches, toString
-
Constructor Details
-
FileURLConnection
Creates an instance ofFileURLConnectionfor establishing a connection to the file pointed by thisURL- Parameters:
url- The URL this connection is connected to
-
-
Method Details
-
connect
This methods will attempt to obtain the input stream of the file pointed by thisURL. If the file is a directory, it will return that directory listing as an input stream.- Specified by:
connectin classURLConnection- Throws:
IOException- if an IO error occurs while connecting
-
getContentLength
public int getContentLength()Returns the length of the file in bytes.- Overrides:
getContentLengthin classURLConnection- Returns:
- the length of the file
- See Also:
getContentType()
-
getContentType
Returns the content type of the resource. Just takes a guess based on the name.- Overrides:
getContentTypein classURLConnection- Returns:
- the content type
-
getInputStream
Returns the input stream of the object referred to by thisURLConnectionFile Sample : "/ZIP211/+/harmony/tools/javac/resources/javac.properties" Invalid File Sample: "/ZIP/+/harmony/tools/javac/resources/javac.properties" "ZIP211/+/harmony/tools/javac/resources/javac.properties"- Overrides:
getInputStreamin classURLConnection- Returns:
- input stream of the object
- Throws:
IOException- if an IO error occurs
-
getPermission
Returns the permission, in this case the subclass, FilePermission object which represents the permission necessary for this URLConnection to establish the connection.- Overrides:
getPermissionin classURLConnection- Returns:
- the permission required for this URLConnection.
- Throws:
IOException- if an IO exception occurs while creating the permission.
-