Lunarpages Web Hosting Forum

Author Topic: How can I create and modify files using Java?  (Read 1037 times)

Offline liars02

  • Newbie
  • *
  • Posts: 2
How can I create and modify files using Java?
« on: April 10, 2004, 10:12:06 AM »
I tried to create a directory under public_html/WEB-Inf/classes called configuration where I want to store my logins.

I am pretty not everyone can create files on my server, so how do I do it?

File file = new File("configuration"); //what is exact uri?
boolean b = file.mkdir();
FileWriter writer = new FileWriter("configuration/login_account.xml");
         out = new PrintWriter(writer); //what is exact uri?


Thanks

Offline davehibshman

  • Newbie
  • *
  • Posts: 4
How can I create and modify files using Java?
« Reply #1 on: May 22, 2004, 07:30:53 PM »
If this is a JAVA applet running on a web page and you wish it to create a file on your server, then this will not work because your applet is downloaded as part of the web page and this code is trying to execute on the client.  It fails because JAVA security will not let downloaded applet code create dirs and files on client machines.  I am not sure if this is what you are trying to do or not.  Maybe this is a servlett?  Just a plain old java applicaton?

Offline JoeK

  • Intergalactic Superstar
  • *****
  • Posts: 126
How can I create and modify files using Java?
« Reply #2 on: July 19, 2004, 08:05:49 AM »
1) Dave is right, if it's an applet, it won't work.  Period.  And I don't think LP will let you run Java applications, but if it's a servlet or a JSP, you're OK...so on with the show...

The uri to the file you are trying to write should be /home/<your_username>/public_html/WEB-INF/classes/configuration

Does that solve your problem?