# [java] Signed applet writing to file

## Recommended Posts

I have a signed applet, and I'm trying to either create a .dat or .txt file or access one that's already there on a website. It's just flat out not working though.. Should I use a URLConnection? And what should I use to write to the file? Thanks for the help.

##### Share on other sites
Well, basically you just create a FileWriter (using the filename in its constructor) and write something to it:

FileWriter fw = new FileWriter("myFile.txt");fw.write(...);fw.close();

##### Share on other sites
Not quite that easy I'm afraid. I've already tried output streams, buffered writers and the like. When I didn't specify a URL to write to, it wrote to my AOL downloaded content folder, and the webmaster's mozilla folder. I know how to read and write to files normally, but when it's online it doesn't quite seem to work. Thanks for you reply though.

##### Share on other sites

URL url;StringBuffer buffer;int responseCode;HttpURLConnection connection = null;InputStream input;BufferedReader bReader;url = new URL(filename);connection = (HttpURLConnection) url.openConnection();responseCode = connection.getResponseCode();buffer = new StringBuffer();input = connection.getInputStream();bReader = new BufferedReader(new InputStreamReader(input));

## Create an account

Register a new account

• ### Forum Statistics

• Total Topics
628401
• Total Posts
2982456

• 9
• 10
• 9
• 19
• 24