it is not important where you run it. your local machine is in the moment of the appletviewer-start an client too. Ok? your machine is splitted into a server and a client so it does not matter that it is the same machine. the appletviewer makes there a real difference. for the viewer exists two different machines at this moment.
also an applet never gets the right to write on a client
Hi
you can create a file on the local file system using applet that is running in an appletviewer. because applet viewer donot have as much restrictions as the browser. I have created a file and here is the code.
import java.awt.*;
import java.awt.event.*;
import java.applet.*;
import java.io.*;
public class writerApplet extends Applet
{
boolean isStandalone = false;
//Get a parameter value
public String getParameter(String key, String def)
{
return isStandalone ? System.getProperty(key, def) :
(getParameter(key) != null ? getParameter(key) : def);
}
//Construct the applet
public writerApplet()
{
}
//Initialize the applet
public void init()
{
try{
PrintWriter file = new PrintWriter(new FileOutputStream("C:\\a.txt"));
file.println("HI...........");
file.println("Sending data to the file.");
file.println("bye");
file.close();
}catch(IOException e){
System.out.println(e.getMessage());
e.printStackTrace();
}
}
public void paint(Graphics g){
g.drawString("File has been written to C:\\a.txt successfully.", 10, 10);
}
}
I hope it would do help
bye