Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4127567

URL.getFile prepend unnecessary "/" to file name

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P3 P3
    • 1.2.0
    • 1.1.5, 1.1.6
    • core-libs
    • None
    • 1.2beta4
    • x86
    • windows_95
    • Not verified

      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) {}
        }
      }

            mmcclosksunw Michael Mccloskey (Inactive)
            duke J. Duke
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: