Hi people,
I'm new to the java world and have a very basic question. I have implemented a servlet which is accessing a file (part of the web project) using absolute path:
File fofile = new File("C:/work/Project/IBNSubscriberServlet/src/com/ibn/util/g7.xsl");
FileInputStream file = new FileInputStream(fofile);
Transformer transformer = TransformerFactory.newInstance().newTransformer(new StreamSource(new FileInputStream(fofile)));
The above works fine. But what i want to do is to set the path above relative to my project. The above servlet code is in a class file
C:/work/Project/IBNSubscriberServlet/src/com/ibn/util/g7Transformer.java
, which is accessed through a servlet
C:/work/Project/IBNSubscriberServlet/src/com/ibn/servlets/SubscriberServlet.java
. note: "util" and "servlets" folder difference.
So my question is how can i set the file path "relative" so that when i place this project on some other machine (along with the g7.xsl), the file is still accessible.
On my changing the file path to just
g7.xsl
instead of absolute path
File fofile = new File("C:/work/Project/IBNSubscriberServlet/src/com/ibn/util/g7.xsl");
it does not work.
Please help.