Reading file from a class that is called by a servlet
I have a servlet, say A. Within the servlet, I make an obejct of another class, say B(this one is just a normal java class, not a servlet). And I want to use class B to open, read a text file and send it to servlet A. The servlet A will then send it back to client.
My question is, since B is just a normal class file and not a java servlet, can I use the FileInputStream in B to open a file? I know that getServletContext().getResourceAsStream("file.txt" ); is better for servlets but since I want to open the file from a normal java class(that is called by a servlet), I think it should be possible. However, when I try it, I get a FileNotFoundException. I am working on eclipse. Any suggestions will be highly appreciated.