Hi, That's a misleading answer. Using the FileInputStream approach, unless you specify an absolute path your results will depend on what the current directory ($CWD) is when you start the server. Not everyone starts it from TOMCAT_HOME/bin.
The first answer posted, using getResource() or getResourceAsStream() is better because it does not have the above dependency and will work out of a WAR. Yoav Shapira Millennium ChemInformatics >-----Original Message----- >From: [EMAIL PROTECTED] >[mailto:[EMAIL PROTECTED]] >Sent: Monday, August 12, 2002 12:34 PM >To: Tomcat Users List >Subject: Re: Reading from files in servlet from Tomcat-4.0.4 > >Hi, > >you need to put the file in /TOMCAT_HOME/bin > >I had the same problem and first I made a simple servlet code that writes >a txt file, then I look for that file and Tomcat put it in >/TOMCAT_HOME/bin > >regards >Alex Tomita > > > > > > >khozaima shakir <[EMAIL PROTECTED]> >10/08/2002 04:30 p.m. >Please respond to Tomcat Users List > > > To: [EMAIL PROTECTED] > cc: > Subject: Reading from files in servlet from Tomcat-4.0.4 > > > >Hi all, >I am trying to read from a file : filename >Where should i put this file in tomcat 4.0.4 directory structure? >I tried putting the file in directories: >webapps/ROOT, webapps/ROOT/WEB-INF, webapps/ROOT/WEB-INF/classes in each >instance i get the error message >"The system cannot find the file specified" > >I used following statement in servlet code. >bufferin = new BufferedReader(new InputStreamReader(new >FileInputStream(fileName))); > >Thanks >Khozaima > > >_________________________________________________________________ >Chat with friends online, try MSN Messenger: http://messenger.msn.com > > >-- >To unsubscribe, e-mail: <mailto:tomcat-user- >[EMAIL PROTECTED]> >For additional commands, e-mail: <mailto:tomcat-user- >[EMAIL PROTECTED]> > > -- To unsubscribe, e-mail: <mailto:[EMAIL PROTECTED]> For additional commands, e-mail: <mailto:[EMAIL PROTECTED]>