If I call URL.getFile from Windows, the name it returns has a "\" prepended. For example, the URL for "file:c:\WINDOWS\TEMP" will return the file name "/c:\WINDOWS|TEMP".
This is potentially harmful, as there is another bug in the File class that causes mkdir to work with the mangled filename, and delete to fail (see related bug).
Test case:
import java.net.*;
public class URLTest {
public static void main(String[] args) {
try {
URL url = new URL("file:c:\\WINDOWS\\TEMP");
System.out.println(url.getFile());
} catch (MalformedURLException e) {}
}
}
This is potentially harmful, as there is another bug in the File class that causes mkdir to work with the mangled filename, and delete to fail (see related bug).
Test case:
import java.net.*;
public class URLTest {
public static void main(String[] args) {
try {
URL url = new URL("file:c:\\WINDOWS\\TEMP");
System.out.println(url.getFile());
} catch (MalformedURLException e) {}
}
}
- relates to
-
JDK-4127582 File.delete() doesn't work with same name used for File.mkdir() on Windows
- Closed