Get ur Duke Dollars Fast

how to allow a applet to create a file in the local machine . examples and codes pleaseThanks in advance
[125 byte] By [sameera_cmca] at [2007-9-26 4:11:40]
# 1
it is prohibited to create a file in the virtual machine, because an applet can only write on the server where it is stored and has no permissions to modifie any data on the clientmachine on which the vm is running
swingfreak at 2007-6-29 13:16:50 > top of Java-index,Desktop,Core GUI APIs...
# 2
i want it on the local machine not the client ie i am running the applet by using the appletviewer any other possible way
sameera_cmca at 2007-6-29 13:16:50 > top of Java-index,Desktop,Core GUI APIs...
# 3

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

swingfreak at 2007-6-29 13:16:50 > top of Java-index,Desktop,Core GUI APIs...
# 4
The why are the Policy Tool Created , plxz can u explain
sameera_cmca at 2007-6-29 13:16:50 > top of Java-index,Desktop,Core GUI APIs...
# 5

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

adnan 027 at 2007-6-29 13:16:50 > top of Java-index,Desktop,Core GUI APIs...
# 6
Hi Sameer! Here's a link that clearly explains the security aspect as it pertains to applets. http://java.sun.com/docs/books/tutorial/applet/practical/security.htmlHope this helps!Cheers!
amolk at 2007-6-29 13:16:50 > top of Java-index,Desktop,Core GUI APIs...