Commit 23f99379 by Anthony Green Committed by Anthony Green

File.java (toURI): Merge from Classpath.

2004-07-05  Anthony Green  <green@redhat.com>
                                                                                                                                               * java/io/File.java (toURI): Merge from Classpath.

From-SVN: r84145
parent 5377d5ba
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
......
......@@ -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.
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment