tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Jeffrey Winter" <jeffreywin...@attbi.com>
Subject Re: getCanonicalFile()
Date Fri, 10 Jan 2003 22:57:01 GMT

> If you need to reference files in some arbitrary directory someplace, you
> should pass the pathname of that directory to your servlet as an init
> parameter, and then use that path to construct an absolute path to the
> file you want.

In my particular case the files I'm attempting to open are ones that are
being created and read by the application itself and are not deployed as
part of the web application.

I actually am passing in a directory name as a <context-param> though
this name has not path in it, it's just the flat name of the directory,
e.g., "somedir".  This value is read in in the init() method, so when
I create the file path I do essentially:

    File file = new File(directory + File.separator + "filename");

Granted, the absolute directory is relative to the context that Tomcat
itself is running in, but that is perfectly fine in my case (I would
think...).

My real issue is that I don't understand why

    InputStream stream = new FileInputStream(file);

would be any different from

    InputStream stream = new FileInputStream(file.getCanonicalFile());

When

    file.getAbsolutePath();   and
    file.getCanonicalFile().getAbsolutePath();

return the exactly the same string.

Thanks


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


Mime
View raw message