Sign in to follow this  
saruthemonkey

[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 this post


Link to post
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 this post


Link to post
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 this post


Link to post
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));

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this