slogum
February 24th, 2010, 07:48 PM
Hi.
I'm running tomcat. I am trying to write to a txt-file on the server from a servlet, but the txt-file allways end up getting stored in my home-folder.
try {
out = new PrintWriter(new FileWriter("test.txt"));
out.print("This is a text");
out.flush();
out.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
When I run this the file "test.txt" is getting stored in my home folder. I've tried a couple of things, like specifying a direct link to where on the server I want it stored, but it still ends up in my home folder.
Like this:
out = new PrintWriter(new FileWriter("/usr/local/tomcat/webapps/app/test.txt"));
This doesent work either.
Any tips? :)
I'm running tomcat. I am trying to write to a txt-file on the server from a servlet, but the txt-file allways end up getting stored in my home-folder.
try {
out = new PrintWriter(new FileWriter("test.txt"));
out.print("This is a text");
out.flush();
out.close();
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
When I run this the file "test.txt" is getting stored in my home folder. I've tried a couple of things, like specifying a direct link to where on the server I want it stored, but it still ends up in my home folder.
Like this:
out = new PrintWriter(new FileWriter("/usr/local/tomcat/webapps/app/test.txt"));
This doesent work either.
Any tips? :)