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

java.io.File.getParent cannot handle mixed slashes

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Duplicate
    • Icon: P4 P4
    • None
    • 1.2.0
    • core-libs
    • x86
    • windows_nt



      Name: rm29839 Date: 03/05/98


      If you construct a java.io.File with a filename
      which contains forward slashes, the filename parsing
      routines getParent() and getName() don't do the
      right thing, even though everything else about the
      interface works fine.

      Consider the following fragment:
      File f = new File("C:/temp/dir1/dir2/fname");
      System.out.print("Your file ")
      if( f.exists())
         System.out.println("exists");
      else{
         System.out.println("doesn't exist. Please create it.");
         System.exit(0);
      }

      System.out.println("The parent is ["+f.getParent()+"]");
      System.out.println("The name is ["+f.getName()+"]");
      // parent aways returns empty
      // name always contains the whole string.

      At least be consistent!
      (Review ID: 25941)
      ======================================================================

            mr Mark Reinhold
            rmandelsunw Ronan Mandel (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: