| Author |
trouble finding a text file to read into an array
|
Jim Bauer
Greenhorn
Joined: Nov 07, 2005
Posts: 9
|
|
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
Joined: Dec 11, 2004
Posts: 13410
|
|
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)
|
Java API J2EE API Servlet Spec JSP Spec How to ask a question... Simple Servlet Examples jsonf
|
 |
 |
|
|
subject: trouble finding a text file to read into an array
|
|
|