This week's giveaway is in the Spring forum.
We're giving away four copies of REST with Spring (video course) and have Eugen Paraschiv on-line!
See this thread for details.
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

Win a copy of REST with Spring (video course) this week in the Spring forum!
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!