tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Will Hartung" <wi...@msoft.com>
Subject Re: Properties file [SOLVED?]
Date Wed, 26 Feb 2003 19:59:09 GMT
> From: "Craig R. McClanahan" <craigmcc@apache.org>
> Sent: Wednesday, February 26, 2003 11:37 AM
> Subject: RE: Properties file [SOLVED?]




> > From: José Moreira <jmoreira@e-terno.net>
> > String path =
> >
this.getClass().getClassLoader().getResource("config.properties").getPath().
> > toString();
> >
> > FileInputStream in = new FileInputStream(path);

> You are working too hard.  :-)

> InputStream is = getClass().getResourceAsStream("config.properties");

Now, as a nit, it would seem to me that not only is he working too hard, but
what he is doing may not even work. The assumption is that getResource will
return a URL to which the getPath part actually points to a File. That's not
guaranteed at all, I don't believe, particularly if the resource is buried
in a JAR.

I imagine that the better way to "work too hard" here would be "simply":

InputStream in =
this.getClass().getClassLoader().getResource("config.properties").openStream
()

Regards,

Will Hartung
(willh@msoft.com)




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


Mime
View raw message