Here is the full patch for UrlFileObject again.

Sincerely,
Anthony Eden
Index: UrlFileObject.java
===================================================================
RCS file: 
/home/cvspublic/jakarta-commons-sandbox/vfs/src/java/org/apache/commons/vfs/provider/url/UrlFileObject.java,v
retrieving revision 1.6
diff -r1.6 UrlFileObject.java
59a60
> import java.io.IOException;
60a62,63
> import java.net.URLConnection;
> import java.net.HttpURLConnection;
99a103,122
>     
>     /**
>      * Returns the last modified time of this file.  Is only called if
>      * [EMAIL PROTECTED] #doGetType} does not return [EMAIL PROTECTED] 
> FileType#IMAGINARY}.
>      */
>     protected long doGetLastModifiedTime() throws Exception
>     {
>         InputStream in = null;
>         try
>         {
>             URLConnection conn = url.openConnection();
>             conn.connect();
>             in = conn.getInputStream();
>             return conn.getLastModified();
>         } 
>         finally 
>         {
>             close(in);
>         }
>     }
106c129,131
<         // Attempt to connect
---
>         FileType fileType = FileType.FILE;
>         // Attempt to connect & check status
>         InputStream in = null;
109c134,143
<             url.openConnection().connect();
---
>             URLConnection conn = url.openConnection();
>             conn.connect();
>             in = conn.getInputStream();
>             if (conn instanceof HttpURLConnection)
>             {
>                 int status = ((HttpURLConnection)conn).getResponseCode();
>                 // 200 is good, maybe add more later...
>                 if ( HttpURLConnection.HTTP_OK != status)
>                     fileType = FileType.IMAGINARY;
>             }
111c145
<         catch ( final FileNotFoundException e )
---
>         catch (final Exception e)
113c147
<             return FileType.IMAGINARY;
---
>             fileType = FileType.IMAGINARY;
115,116c149,153
< 
<         return FileType.FILE;
---
>         finally
>         {
>             close(in);
>         }
>         return fileType;
124c161,171
<         return url.openConnection().getContentLength();
---
>         InputStream in = null;
>         try
>         {
>             URLConnection conn = url.openConnection();
>             in = conn.getInputStream();
>             return conn.getContentLength();
>         }
>         finally 
>         {
>             close(in);
>         }
140a188,202
>     }
>     
>     private void close(InputStream in)
>     {
>         if (in != null)
>         {
>             try
>             {
>                 in.close();
>             }
>             catch (final IOException e)
>             {
>                 
>             }
>         }



---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to