commons-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From bugzi...@apache.org
Subject DO NOT REPLY [Bug 29351] New: - FilenameUtils#removeExtensionand FilenameUtils#getExtension don't handle all cases.
Date Thu, 03 Jun 2004 03:27:03 GMT
DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://issues.apache.org/bugzilla/show_bug.cgi?id=29351>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://issues.apache.org/bugzilla/show_bug.cgi?id=29351

FilenameUtils#removeExtensionand FilenameUtils#getExtension don't handle all cases.

           Summary: FilenameUtils#removeExtensionand
                    FilenameUtils#getExtension don't handle all cases.
           Product: Commons
           Version: 1.0 Final
          Platform: Other
        OS/Version: Other
            Status: NEW
          Severity: Normal
          Priority: Other
         Component: IO
        AssignedTo: commons-dev@jakarta.apache.org
        ReportedBy: oliver@deeper.co.nz


public static String getExtension( String filename) {
    int index = filename.lastIndexOf('.');

    if (-1 == index) {
        return "";
    } else {
        return filename.substring(index + 1);
    }
}

is too simplistic.

It will not handle paths in the form "/path.to/file" at all well.  It will
return "to/file" as the extension which is incorrect.  The file extension is "".

removeExtension falls into a similar trap.

Perhaps it was the poor quality of these functions that caused FilenameUtils to
be removed from the 1.0 release?

---------------------------------------------------------------------
To unsubscribe, e-mail: commons-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: commons-dev-help@jakarta.apache.org


Mime
View raw message