tomcat-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "mailinglist@j-b-s.de" <mailingl...@j-b-s.de>
Subject Re: R: how to read files in file system
Date Tue, 18 Sep 2012 06:37:41 GMT
Try:

URI uri = new URI("file//c:/.."); // win

Or 

"file:///yourdir/.." on unix (note 3 "/").

From uri you can get the url and from here you can open an inputstream or you can use "new
File(url.toFile())"

To access a resource from your classpath the following will do:

URL url = Thread.currentThread().getContextClassloader().getResource("relativeNameOfFile");

Basically this should work, but its untested as my phone does not provide a java compiler
:-)

Jens

Sent from my iPhone

On 18.09.2012, at 08:21, "Ge Gestione Elaboratori\(IBM Business Partner\)" <casemie@gmail.com>
wrote:

> Excuse me Dan:
> attached the screenshot.
> paolo
> 
> -----Messaggio originale-----
> Da: Daniel Mikusa [mailto:dmikusa@vmware.com] 
> Inviato: martedì 11 settembre 2012 13.51
> A: Tomcat Users List
> Oggetto: Re: how to read files in file system
> 
> On Sep 11, 2012, at 3:11 AM, IBM partner Gestione Elaboratori wrote:
> 
>> With jsp i can read files in the file system only if there are located
> under
>> the directory webapps/<application>/<file>.
>> 
>> If I read a file ,for example, in c:/<filename> Tomcats signals an error
> (se
>> atthachment)
> 
> Again, there is no attachment.  The list is probably removing it.  Please
> try pasting the content into your email.
> 
> Please also include the error that is given.  Without that, we can only
> guess at what is happening.
> 
> Dan
> 
>> How to read files located everywere in the file system?
>> 
>> 
>> 
>> paoloc
>> 
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org
> 
> 
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: users-unsubscribe@tomcat.apache.org
> For additional commands, e-mail: users-help@tomcat.apache.org

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


Mime
View raw message