• Post Reply Bookmark Topic Watch Topic
  • New Topic

trouble finding a text file to read into an array  RSS feed

 
Jim Bauer
Greenhorn
Posts: 9
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm having trouble reading a text file from a couple of classes that are served up from servlets via jsp.
What I'm doing is reading the file into an array and building from there.

String fileread = "bauerquarterhorses.com\\Combined.txt";
LoadArray2 newarray = new LoadArray2();
newarray.SetArray(fileread);

I've moved my Combined.txt file all over and it can't seem to find it.

It works fine on my machine. But I have to specify where on my c: drive to look for the file. How do I get the class on the web site to know where to look?

any help would be appreciated!!

Thanks
 
Ben Souther
Sheriff
Posts: 13411
Firefox Browser Redhat VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the file is within your web applications folder hierarchy the best method is ServletContext.getResourceAsStream.
java.lang.String)" target="_blank" rel="nofollow">http://java.sun.com/j2ee/1.4/docs/api/javax/servlet/ServletContext.html#getResourceAsStream(java.lang.String)
 
Consider Paul's rocket mass heater.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!