The Artima Developer Community
Sponsored Link

Legacy Java Answers Forum
July 2001



This page contains an archived post to the Java Answers Forum made prior to February 25, 2002. If you wish to participate in discussions, please visit the new Artima Forums.


I/O with applets

Posted by Bryan on February 19, 2002 at 7:51 PM

> > > > How do you read a text file using an applet?
> > > You don't! That's the point of applets: they can't muck with your files. (If they could, they would be called "viruses" in most cases).
> > > - MFG
> >
> > thats crap, unless the applet writes, then can it be considered hostile, not reading
> > an example

> Speaking of crap, did you actually try the example at the end of your URL? Try and compile it. Good luck.

> Yes, an applet can read a text file, as long as it is on the server from which the applet is running. That's not completely useless, but close.

> The original post didn't say what the location of the text file would be, but I assumed it was talking about opening files on the client machine. Of course, if you only read a file on the client machine, it would be a huge security problem, but not a virus problem. However, what I said was that applets don't allow you to muck with files [on the client machine], so you obiously didn't look up "muck" to understand what I meant, but English (along with civility) doesn't seem to be one of your strengths, anyway.

> Anyhow, I don't know exactly what the orginal poster wanted, but if it is modifying files on the client machine, then a signed applet or application would be the solution, not an applet.

> - mfg

You can perform file I/O with applets. Java's security manager
requires you to create a policy file first. Check out Sun's
website for examples of how to do this. Then you need to include
some code in your applet telling Java to check your policy file.
I'm working on this same problem, so I'm still running down the
code. I do have my I/O working if I pass the policyFile arguments
directly to appletviewer in a UNIX environment, but that isn't of
much use as most people will be running your applet in a browser.


Sponsored Links

Copyright © 1996-2009 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use - Advertise with Us