Aparna Nayak
Aparna Nayak

Reputation: 23

How to save images created in applet to specified folder?

share1 = (BufferedImage) createImage(new MemoryImageSource(w*2,h,s1,0,w*2));
ImageIO.write(share1, "jpg", fileChooser.getSelectedFile());

Upvotes: 0

Views: 466

Answers (2)

Andrew Thompson
Andrew Thompson

Reputation: 168845

Besides digitally signing the code, there is another method for newer JREs. The more recent 'next generation'/'plug-in' 2 JREs support launching embedded applets using Java Web Start. Once an applet is deployed using JWS, it can use the JNLP API services, which include APIs that allow a sand-boxed applet to read from or write to the local file-system.

Here is a small demo of the file services. That demo. is not an applet. For an example of an applet that uses the services, see the GIFanim applet.

Upvotes: 2

alexey28
alexey28

Reputation: 5230

You should sign your applet with certificate (can use key tool from JDK to generate your own certificate).

After sign of your applet with this certificate client that load applet will be prompted to accept it. If the client accepts it - you can write your images from applet to local user PC.

Otherwise it is restricted by security.

Upvotes: 3

Related Questions