|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
#1
|
|||
|
|||
|
Servlet reading a file...
Hello,
How do I get a servlet to read a file? I need to read a .txt file and store its contents in a String variable. However, no matter where I put the .txt file, the servlet never seems to find it. Thanks |
|
#2
|
|||
|
|||
|
Here's the class to use:
http://java.sun.com/j2se/1.3/docs/a...FileReader.html I'd suggest wrapping it in a BufferedReader, like Code:
BufferedReader in = new BufferedReader(new FileReader("foo.in"));
then you can use the readLine method from BufferedReader. |
|
#3
|
|||
|
|||
|
Servlets read files just as any other Java application does. You will need to import the java.io.* package.
|
![]() |
| Viewing: Dev Shed Forums > Programming Languages > Java Help > Servlet reading a file... |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|