JDK-4123637 : java.io.File.getParent() returns "/u/test" as the parent of "/u/test/"
  • Type: Bug
  • Component: core-libs
  • Sub-Component: java.io
  • Affected Version: 1.1.5,1.2.0
  • Priority: P4
  • Status: Closed
  • Resolution: Fixed
  • OS: generic,solaris_2.5.1,windows_95
  • CPU: generic,x86,sparc
  • Submitted: 1998-03-27
  • Updated: 1999-01-15
  • Resolved: 1999-01-15
The Version table provides details related to the release that this issue/RFE will be addressed.

Unresolved : Release in which this issue/RFE will be addressed.
Resolved: Release in which this issue/RFE has been resolved.
Fixed : Release in which this issue/RFE has been fixed. The release containing this fix may be available for download as an Early Access Release or a General Availability Release.

To download the current JDK release, click here.
Other
1.2.0 1.2beta4Fixed
Related Reports
Duplicate :  
Relates :  
Description

Name: el35337			Date: 03/27/98


import java.io.*;

public class FileParentBug {

  /**
   * Demonstrate that File.getParent fails on directories with a trailing
   * File.separator.
   *
   * Tested on JDK 1.1.5 and 1.2beta2 running on Solaris 2.5.1
   */
  public static void main(String[] args) {
    File file = new File("/u/test/");
    System.out.println("The parent directory of /u/test/ should be /u (or /u/)")
;
    System.out.println("JDK reports it as : " + file.getParent());
  }
}
(Review ID: 27268)
======================================================================

Comments
CONVERTED DATA BugTraq+ Release Management Values COMMIT TO FIX: generic FIXED IN: 1.2beta4 INTEGRATED IN: 1.2beta4
14-06-2004

WORK AROUND Name: el35337 Date: 03/27/98 String dirname = "/u/test/"; if (dirname.endsWith(File.separator)) { dirname = dirname.substring(0, dirname.length() - 1); } ======================================================================
11-06-2004

EVALUATION Fixed by the general rewrite of java.io.File in JDK 1.2beta4 (4131169). -- mr@eng 6/18/1998
18-06-1998