I have a program that only uses JFrame, not JApplet. This is the first time I have had it throw a security exception with FileInputStream and FileOutputStream. Here is the piece of code that is throwing the exception:
public static Vector<MyEvent> grabEventVector() { Vector<MyEvent> v = new Vector(); try{ FileInputStream f = new FileInputStream("Data.txt"); ObjectInputStream s = new ObjectInputStream(f); v=(Vector<MyEvent>) s.readObject(); s.close(); }catch(Exception e) { error.setText(e.getMessage()); } return v; }
I understand that this is probably not enough of my code to really help. So here is some context:
package todoitbetterapp; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInputStream; import java.io.ObjectOutputStream; import java.util.Vector; import javax.swing.JLabel; public class GlobalClasses { public static JLabel error; public void GlobalClasses() { error = new JLabel(" "); } //Global Methods public static void writeEventVector(Vector<MyEvent> v)//Writes Vector<MyEvent> to file { try{ FileOutputStream f = new FileOutputStream ("Data.txt"); ObjectOutputStream s = new ObjectOutputStream(f); s.writeObject(v); s.flush(); s.close(); }catch(Exception ex) { //error.setText(ex.getMessage()); } } public static Vector<MyEvent> grabEventVector() { Vector<MyEvent> v = new Vector(); try{ FileInputStream f = new FileInputStream("Data.txt"); ObjectInputStream s = new ObjectInputStream(f); v=(Vector<MyEvent>) s.readObject(); s.close(); }catch(Exception e) { error.setText(e.getMessage()); } return v; } }
These methods get called often by several other classes, so I put them all into one convenient class. Please let me know if I need to put more code down.