File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Servlets and the fly likes Saving  file at server Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Servlets
Bookmark "Saving  file at server" Watch "Saving  file at server" New topic

Saving file at server

Manu Syal

Joined: Nov 28, 2000
Posts: 4
I need to save a string as a file at server end . I am using JWS and when I save it using FileWriter it get saved at the JWS root directory. I need to save the file in a paticular directory at web server ie. like http://localhost:/pubic_html/abc .
I am reading the file through this
URL myURL = new URL("http://localhost:8080/template/template.htm");
BufferedReader in= new BufferedReader(new InputStreamReader(myURL.openStream()));
and I am saving like this
FileWriter f1=new FileWriter("reslt.htm");
It get saved at JWS root directory .When I tried giving the full server path with the file name in FileWriter it did not worked
I need to save the file at particular directory ie. virtual directory at the server
Bosun Bello
Ranch Hand

Joined: Nov 06, 2000
Posts: 1510
You may want to try this
File f1=new File("your path\reslt.htm")
FileWriter f2=new FileWriter(f1.getPath());

So much trouble in the world -- Bob Marley
I agree. Here's the link:
subject: Saving file at server
It's not a secret anymore!