jakarta-cactus-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "J. B. Rainsberger" <jbra...@rogers.com>
Subject Re: Code Review (Re: "You must either set location or path on <pathelement>" Exception Message)
Date Sat, 29 Nov 2003 11:17:32 GMT
Vincent Massol wrote:

> 
>>-----Original Message-----
>>From: J. B. Rainsberger [mailto:jbrains@rogers.com]
>>Sent: 29 November 2003 11:55
>>To: Cactus Users List
>>Subject: Re: Code Review (Re: "You must either set location or path on
>><pathelement>" Exception Message)
>>
>>Vincent Massol wrote:
>>
>>
>>>>-----Original Message-----
>>>>From: J. B. Rainsberger [mailto:jbrains@rogers.com]
>>>>Sent: 28 November 2003 23:55
>>>>To: Cactus Users List
>>>>Subject: Code Review (Re: "You must either set location or path on
>>>><pathelement>" Exception Message)
>>>>
>>>>Vincent Massol wrote:
>>>>
>>>>
>>>>
>>>>>       File toolsJar = new File(javaHome + "/../lib/tools.jar");
>>>>
>>>>I think this could and /should/ be
>>>>
>>>>    new File(javaHome, "../lib/tools.jar");
>>>
>>>
>>>Are you confident javaHome will always contain a trailing "/"?
>>
>>No. That's the point of using 'new File(directory, relativePath)'. The
>>nice Java folks have already worried about trailing slash or not
>>trailing slash. Why should /we/ worry about it?
> 
> 
> Cool. I didn't know that :-) BTW, I've had a look at the JDK 1.4 javadoc
> for File and I couldn't see this mentioned anywhere. Are you sure this
> is an exposed feature or simply an implementation detail of the Sun's
> JDK?

The parent path (the first parameter) is "taken to be a directory" 
[Javadoc], so it doesn't matter whether the parent path you specify ends 
in "/" -- File treats it like a directory, anyway. The relative path is 
always taken from the directory represented by the parent path. The 
whole point of the constructor is to avoid this entire trailing slash 
issue! :)
-- 
J. B. Rainsberger,
Diaspar Software Services
http://www.diasparsoftware.com :: +1 416 791-8603
Let's write software that people understand


Mime
View raw message