Exporting to a text file in an applet..

Hey all,

I've been working on an applet for simulating different nodal configurations on a 2D map. What I need to be able to do is export, on the click of a button, all of the nodal coordinates (x,y) to a text file. However, using the standard FileWrite hasn't been working for me. The code compiles and the applet runs fine, but I haven't been able to create the text file on the click of a button. Any ideas?

Here's what I've got so far. Basically, on the button push, it's supposed goes through an array of ellipses (what I use for nodes) and gets the x and y coords for each and output them to a text file. The applet doesn't freeze or anything when I push the button either, it just does nothing.

void stop_actionPerformed(ActionEvent e){

try

{

String fileName ="NodeCoords.txt";

FileWriter fileWriter =new FileWriter( fileName );

BufferedWriter bufferedWriter =new BufferedWriter( fileWriter );

String tmpCoordinates;

int ID;

//for looop through x-y coordinates

for (int i = 0; i < node.length; i++){

ID = i+1;

tmpCoordinates ="Node: " + String.valueOf(nodeID[ID]) +" X: " + String.valueOf(node[i].getX()) +" Y: " + String.valueOf(node[i].getY()) +"\n";

bufferedWriter.write(tmpCoordinates);

}

bufferedWriter.close();

}

catch( IOException p )

{

p.printStackTrace();

}

}

[2065 byte] By [stogey25a] at [2007-11-27 8:46:37]
# 1
Untrusted applets can't write to files. Why do this in an applet? Why not a regular application?
BigDaddyLoveHandlesa at 2007-7-12 20:49:30 > top of Java-index,Java Essentials,Java Programming...
# 2
I'm new to this type of programming. This is for simulation of a new MAC protocol that I've worked on, and is basically just serving as a visual. If I knew how to create a stand alone application that looks like the applet I would have...
stogey25a at 2007-7-12 20:49:30 > top of Java-index,Java Essentials,Java Programming...
# 3
http://java.sun.com/docs/books/tutorial/uiswing/index.html
BigDaddyLoveHandlesa at 2007-7-12 20:49:30 > top of Java-index,Java Essentials,Java Programming...