DO NOT REPLY TO THIS EMAIL, BUT PLEASE POST YOUR BUG 
RELATED COMMENTS THROUGH THE WEB INTERFACE AVAILABLE AT
<http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19979>.
ANY REPLY MADE TO THIS MESSAGE WILL NOT BE COLLECTED AND 
INSERTED IN THE BUG DATABASE.

http://nagoya.apache.org/bugzilla/show_bug.cgi?id=19979

FileUtils removeLeadingPath method

           Summary: FileUtils removeLeadingPath method
           Product: Ant
           Version: 1.5.2
          Platform: All
               URL: http://nagoya.apache.org/gump/javadoc/ant/build/javadocs
                    /org/apache/tools/ant/util/FileUtils.html
        OS/Version: Other
            Status: NEW
          Severity: Minor
          Priority: Other
         Component: Other
        AssignedTo: [EMAIL PROTECTED]
        ReportedBy: [EMAIL PROTECTED]
                CC: [EMAIL PROTECTED]


The removeLeadingPath method returns the path parameter value, if both the 
leading and the path parameters have same value.  

Ant Version: 1.5.2
FileUtils Version: $Revision: 1.41 $

For example, take a look at the following code:

FileUtils fileUtils = FileUtils.newFileUtils();
File leading = new File("C:/Testing");
File path = new File("C:/Testing");
String s = fileUtils.removeLeadingPath(leading,path);
File resultFile = new File("C:/AntTools/tempwork",s);
try {
System.out.println("After Removing Leading Path "+resultFile.toURL());
} catch (MalformedURLException e) {
e.printStackTrace();
}

The output prints:
After Removing Path file:/C:/AntTools/tempwork/C:/Testing

Now the resultFile points to an invalid path.

Instead if it would have been modified to return an empty string "", then the 

FileUtils fileUtils = FileUtils.newFileUtils();
File leading = new File("C:/Testing");
File path = new File("C:/Testing");
String s = null;
if (path.equals(leading)) {
s = "";
} else {
s = fileUtils.removeLeadingPath(leading,path);
}
File f = new File("C:/AntTools/tempwork",s);
try {
System.out.println("Removed Leading Path "+f.toURL());
} catch (MalformedURLException e) {
e.printStackTrace();
}

The output would be
After Removing Path file:/C:/AntTools/tempwork 

now the resultFile points to a valid path.

Regards,
Shunmuga Sundaram. D

Reply via email to