org.apache.geronimo.system.url.file
Class FileURLConnection

java.lang.Object
  extended byjava.net.URLConnection
      extended byorg.apache.geronimo.system.url.file.FileURLConnection

public class FileURLConnection
extends URLConnection

A URLConnection for the 'file' protocol.

Correctly returns headers.

Version:
$Revision: 1.2 $ $Date: 2004/03/10 09:59:31 $

Field Summary
 
Fields inherited from class java.net.URLConnection
allowUserInteraction, connected, doInput, doOutput, ifModifiedSince, url, useCaches
 
Constructor Summary
FileURLConnection(URL url, File file)
           
 
Method Summary
 void connect()
           
 int getContentLength()
          Returns the length of the file.
 String getContentType()
          Returns the content type of the file as mapped by the filename map.
 long getDate()
          Returns the last modified time of the file.
 File getFile()
           
 String getHeaderField(int n)
           
 String getHeaderField(String name)
          Get a header field by name.
 String getHeaderFieldKey(int n)
           
 Map getHeaderFields()
          Returns supported headers.
 InputStream getInputStream()
          Return the input stream for the file.
 long getLastModified()
          Always return the last-modified from the file.
 OutputStream getOutputStream()
          Return the output stream for the file.
 Permission getPermission()
          Return the permission for the file.
 
Methods inherited from class java.net.URLConnection
addRequestProperty, getAllowUserInteraction, getContent, getContent, getContentEncoding, getDefaultAllowUserInteraction, getDefaultRequestProperty, getDefaultUseCaches, getDoInput, getDoOutput, getExpiration, getFileNameMap, getHeaderFieldDate, getHeaderFieldInt, getIfModifiedSince, getRequestProperties, getRequestProperty, getURL, getUseCaches, guessContentTypeFromName, guessContentTypeFromStream, setAllowUserInteraction, setContentHandlerFactory, setDefaultAllowUserInteraction, setDefaultRequestProperty, setDefaultUseCaches, setDoInput, setDoOutput, setFileNameMap, setIfModifiedSince, setRequestProperty, setUseCaches, toString
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

FileURLConnection

public FileURLConnection(URL url,
                         File file)
                  throws MalformedURLException,
                         IOException
Method Detail

getFile

public File getFile()

connect

public void connect()
             throws IOException
Throws:
IOException

getInputStream

public InputStream getInputStream()
                           throws IOException
Return the input stream for the file.

Sun's URL connections use buffered streams, so we do too.

This impl will return a new stream for each call.

Throws:
IOException

getOutputStream

public OutputStream getOutputStream()
                             throws IOException
Return the output stream for the file.

Sun's URL connections use buffered streams, so we do too.

This impl will return a new stream for each call.

Throws:
IOException

getPermission

public Permission getPermission()
                         throws IOException
Return the permission for the file.

Sun's impl always returns "read", but no reason why we can not also write to a file URL, so we do.

Throws:
IOException

getLastModified

public long getLastModified()
Always return the last-modified from the file.

NOTE: Sun's impl caches this value, so it will appear to never change even if the underlying file's last-modified has changed.


getDate

public long getDate()
Returns the last modified time of the file.


getContentLength

public int getContentLength()
Returns the length of the file.


getContentType

public String getContentType()
Returns the content type of the file as mapped by the filename map.


getHeaderField

public String getHeaderField(String name)
Get a header field by name.

Supported headers:

Hook into our local methods to get headers. URLConnection normally goes the other way around. ie. URLConnection.getDate() calls getHeaderField('date'), but for file usage this is wasteful string creation as normally the getHeaderField() will not be called.


getHeaderFields

public Map getHeaderFields()
Returns supported headers.

See Also:
getHeaderField(java.lang.String)

getHeaderFieldKey

public String getHeaderFieldKey(int n)

getHeaderField

public String getHeaderField(int n)


Copyright © 2003-2005 Apache Software Foundation. All Rights Reserved.