Vincent Massol wrote:


-----Original Message-----
From: J. B. Rainsberger [mailto:[EMAIL PROTECTED]
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:[EMAIL PROTECTED]
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



--------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]



Reply via email to