2003-12-02 Michael Koch <konqueror@gmx.de>
authorMichael Koch <konqueror@gmx.de>
Tue, 2 Dec 2003 14:36:22 +0000 (14:36 +0000)
committerMichael Koch <mkoch@gcc.gnu.org>
Tue, 2 Dec 2003 14:36:22 +0000 (14:36 +0000)
* gnu/java/net/protocol/file/Connection.java
(getLastModified): Implement for file connections.
(getContentLength): Likewise.

From-SVN: r74180

libjava/ChangeLog
libjava/gnu/java/net/protocol/file/Connection.java

index 3e9b3d517d2a28a048fd51436efda519e64c74e6..f652a2cf7b4948ce837bcd46b529ec78fc8c5e35 100644 (file)
@@ -1,3 +1,9 @@
+2003-12-02  Michael Koch  <konqueror@gmx.de>
+
+       * gnu/java/net/protocol/file/Connection.java
+       (getLastModified): Implement for file connections.
+       (getContentLength): Likewise.
+
 2003-12-02  Michael Koch  <konqueror@gmx.de>
 
        * gnu/java/net/protocol/file/Connection.java:
index fcae745e1308254b90ae98b1eb10165def9d5ac7..bd3c915a3d060bae5335ee87c1e8583ab0091ef9 100644 (file)
@@ -164,7 +164,46 @@ public class Connection extends URLConnection
     return outputStream;
   }
 
-  // Override default method in URLConnection.
+  /**
+   * Get the last modified time of the resource.
+   *
+   * @return the time since epoch that the resource was modified.
+   */
+  public long getLastModified()
+  {
+    try
+      {
+       if (!connected)
+         connect();
+
+       return file.lastModified();
+      }
+    catch (IOException e)
+      {
+       return -1;
+      }
+  }
+
+  /**
+   * Get the length of content.
+   *
+   * @return the length of the content.
+   */
+  public int getContentLength()
+  {
+    try
+      {
+       if (!connected)
+         connect();
+        
+       return (int) file.length();
+      }
+    catch (IOException e)
+      {
+       return -1;
+      }
+  }
+  
   /**
    * This method returns a <code>Permission</code> object representing the
    * permissions required to access this URL.  This method returns a