I want to convert my command line app to an applet. My command line app uses plain text files to load some data that program needs. When I implement this class in an applet it can't read the file (eventhough it's in the same directory). I use this principle to load files:
What do I need to change? And are there some visual component which can display my System.out.println("")? I mainly want to make it into an applet to make distribution easier, but the output of the program can still come in some sort of text window (which one?). [ January 07, 2007: Message edited by: Tim Pintens ]
As a security precaution, applets are not allowed to perform file I/O. There are two principal ways around that: digitally signing the applet, and aletring the local security policy. Both are outlined here.
The output of System.out goes to the Java Console, which you can open either through a menu in the browser, or through the little Java icon in the Windows tray. On OS X , you'd use Console.app.
But if the program has only text input and output, why make it an applet? Maybe a WebStart application would be more appropriate?
Joined: Dec 17, 2006
I think I didn't make myself clear enough: the file it has to load recides on the host. I do not want access to the local filesystem of the user. The program accually uses a textfile as a small database to get data. For example if I would like to make an applet which gives back the capital of the country when a country is selected out of a list. Can't I just use a textfile which holds comma-separated text to find the capital.
Example of what the textfile would hold: France,Paris Germany,Berlin UK,London
I do not want to put this data directly into the program, because I want it to be dynamically i.e. I want to be able to at capitals without changing the program, but only changing the textfile.
Joined: Mar 22, 2005
That makes more sense. You can use HTTP to retrieve the file. It could be as simple as
At which point you can use String methods to parse the file contents into its various parts. [ January 07, 2007: Message edited by: Ulf Dittmer ]