This week's book giveaway is in the Clojure forum.
We're giving away four copies of Clojure in Action and have Amit Rathore and Francis Avila on-line!
See this thread for details.
Win a copy of Clojure in Action this week in the Clojure forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

problem while reading in servlet..!

 
Jack Doson
Greenhorn
Posts: 9
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Iam developing a web Application named cabworker

in that application i created "media" directory and i placed a text file called dates.txt in that directory.

now iam reading that file inside a servlet like this.

FileReader fw=new FileReader("media/dates.txt");

here it is giving exception like file specified not found(but it is compiling properly)..!

when i tried to read like

FileReader fw=new FileReader("/media/dates.txt");
still it is same exception..!

please help me in this regard.!
 
Satish Chilukuri
Ranch Hand
Posts: 266
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
FileReader takes in an file system path. In your case it is looking for the file /media/dates.txt on your file system and not in your web application. You can use the ServletContext's getRealPath() to convert a web application path to the file system path and then pass it to FileReader.
 
I agree. Here's the link: http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic