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

File URL returned by Class.getResource() is invalid

    XMLWordPrintable

    Details

    • Type: Bug
    • Status: Closed
    • Priority: P4
    • Resolution: Not an Issue
    • Affects Version/s: 1.1.7
    • Fix Version/s: None
    • Component/s: core-libs
    • Labels:
    • Subcomponent:
    • CPU:
      x86
    • OS:
      windows_nt

      Description



      Name: dbT83986 Date: 03/25/99


      The URL returned by Class.getResource() cannot be used
      to open a file:

      import java.io.File;
      import java.io.IOException;
      import java.net.URL;

      public class Tst
      {
          public static void main(String[] args) throws IOException
          {
              URL iniURL = Tst.class.getResource("tst.ini");
              System.out.println(iniURL);
              File iniFile = new File(iniURL.getFile());
              System.out.println(iniFile + ".exists() == "+ iniFile.exists());
              System.out.println(iniFile + ".getCanonicalPath() = " + iniFile.getCanonicalPath());
              File iniFile2 = new File(iniFile.getCanonicalPath());
              System.out.println(iniFile2 + ".exists() == "+ iniFile2.exists());
          }
      }

      bash-2.02$ //D/Java/jdk1.1.7/bin/java -version
      java version "1.1.7B"

      bash-2.02$ //D/Java/jdk1.1.7/bin/java Tst
      Symantec Java! JustInTime Compiler Version 3.10.093(x) for JDK 1.1.x
      Copyright (C) 1996-98 Symantec Corporation

      systemresource:/FILE0/+/tst.ini
      /FILE0/+/tst.ini.exists() == false
      /FILE0/+/tst.ini.getCanonicalPath() = D:\FILE0\+\tst.ini
      D:\FILE0\+\tst.ini.exists() == false
      (Review ID: 56084)
      ======================================================================

        Attachments

          Activity

            People

            Assignee:
            apalanissunw Anand Palaniswamy (Inactive)
            Reporter:
            dblairsunw Dave Blair (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Dates

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: