Name: nkR10003 Date: 04/24/2002
The JavaDoc comments for File.toURI() method says:
/**
* ...
*
* For a given abstract pathname f, it is guaranteed that
*
* new File( f.toURI()).equals( f)
*
* so long as the original abstract pathname, the URI, and the new abstract
* pathname are all created in (possibly different invocations of) the same
* Java virtual machine.
* ...
*
*/
This statement does not work.
Example below demonstrates this problem:
------------------example--------------------
import java.io.File;
import java.net.URI;
public class test {
public static void main(String[] args) {
File f = new File("test.txt");
if (!new File(f.toURI()).equals(f)) {
System.out.println("Test failed: new File(f.toURI()) does not equal to f");
System.exit(-1);
}
System.out.println("Test passed");
return;
}
}
----------------output:----------------------
%java -version
java version "1.4.1-beta"
Java(TM) 2 Runtime Environment, Standard Edition (build 1.4.1-beta-b09)
Java HotSpot(TM) Client VM (build 1.4.1-beta-b09, mixed mode)
%java test
Test failed: new File(f.toURI()) does not equal to f
---------------------------------------------
======================================================================