[PATCH] Adding methods to java.io.File.

Alexandre Petit-Bianco apbianco@cygnus.com
Wed Feb 7 23:11:00 GMT 2001


I wrote a patch once to add methods that were reported missing while
building some net packages. Here it is. Let me know what I should do
with it.

./A

2001-02-07  Alexandre Petit-Bianco  <apbianco@redhat.com>

	* java/io/File.java (java.net): Imported.
	(getAbsoluteFile): Added.
	(getCanonicalPath): Likewise.
	(toURL): Likewise.

Index: java/io/File.java
===================================================================
RCS file: /cvs/gcc/gcc/libjava/java/io/File.java,v
retrieving revision 1.14
diff -u -p -r1.14 File.java
--- File.java	2000/09/08 19:37:08	1.14
+++ File.java	2001/02/08 06:25:19
@@ -11,6 +11,7 @@ details.  */
 package java.io;
 
 import java.util.*;
+import java.net.*;
 import gnu.gcj.runtime.FileDeleter;
 
 /**
@@ -106,8 +107,16 @@ public class File implements Serializabl
     return System.getProperty("user.dir") + separatorChar + path;
   }
 
+  public File getAbsoluteFile () throws IOException {
+    return new File (getAbsolutePath());
+  }
+
   public native String getCanonicalPath () throws IOException;
 
+  public File getCanonicalFile () throws IOException {
+    return new File (getCanonicalPath());
+  }
+
   public String getName ()
   {
     int last = path.lastIndexOf(separatorChar);
@@ -176,6 +185,11 @@ public class File implements Serializabl
   public String toString ()
   {
     return path;
+  }
+
+  public URL toURL () throws MalformedURLException
+  {
+    return new URL ("file:" + path + (isDirectory() ? "/" : ""));
   }
 
   private final native boolean performMkdir ();


More information about the Java-patches mailing list