summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorgreen <green@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-06 02:52:54 +0000
committergreen <green@138bc75d-0d04-0410-961f-82ee72b054a4>2004-07-06 02:52:54 +0000
commitbc8eeb65f61f2389605a7f4e37de561c0e6c10e2 (patch)
treebc155c692b8d7595ad016211c488bbc3005e29f2
parent1f8a6ff8484e367b87d47717fae8eacf2deea6da (diff)
downloadgcc-bc8eeb65f61f2389605a7f4e37de561c0e6c10e2.tar.gz
2004-07-05 Anthony Green <green@redhat.com>
* java/io/File.java (toURI): Merge from Classpath. git-svn-id: svn+ssh://gcc.gnu.org/svn/gcc/trunk@84145 138bc75d-0d04-0410-961f-82ee72b054a4
-rw-r--r--libjava/ChangeLog4
-rw-r--r--libjava/java/io/File.java24
2 files changed, 28 insertions, 0 deletions
diff --git a/libjava/ChangeLog b/libjava/ChangeLog
index 4cff650aac7..66f3f41a1d7 100644
--- a/libjava/ChangeLog
+++ b/libjava/ChangeLog
@@ -1,3 +1,7 @@
+2004-07-05 Anthony Green <green@redhat.com>
+
+ * java/io/File.java (toURI): Merge from Classpath.
+
2004-07-05 Bryce McKinlay <mckinlay@redhat.com>
* gnu/gcj/runtime/VMClassLoader.java (init): Check classpath entry
diff --git a/libjava/java/io/File.java b/libjava/java/io/File.java
index 53ae529c6fe..47f18b533b3 100644
--- a/libjava/java/io/File.java
+++ b/libjava/java/io/File.java
@@ -40,6 +40,8 @@ exception statement from your version. */
package java.io;
import java.net.MalformedURLException;
+import java.net.URI;
+import java.net.URISyntaxException;
import java.net.URL;
import gnu.classpath.Configuration;
import gnu.gcj.runtime.FileDeleter;
@@ -875,6 +877,28 @@ public class File implements Serializable, Comparable
}
/**
+ * @return A <code>URI</code> for this object.
+ */
+ public URI toURI()
+ {
+ String abspath = getAbsolutePath();
+
+ if (isDirectory())
+ abspath = abspath + separator;
+
+ try
+ {
+ return new URI("file", "", abspath.replace(separatorChar, '/'));
+ }
+ catch (URISyntaxException use)
+ {
+ // Can't happen.
+ throw (InternalError) new InternalError("Unconvertible file: "
+ + this).initCause(use);
+ }
+ }
+
+ /**
* This method returns a <code>URL</code> with the <code>file:</code>
* protocol that represents this file. The exact form of this URL is
* system dependent.