JFrame java.io.FilePermission
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:
Code :
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:
Code :
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.
Re: JFrame java.io.FilePermission
Please post the full text of the error message.
Change the code by adding a call to printStackTrace in the catch block so you get the FULL error message
Re: JFrame java.io.FilePermission
I figured it out. It was a silly mistake. I working in NetBeans IDE and my configuration was in WebStart... When I changed it to <default config> I no longer got the errors. Since it is more a personal app, I really don't care. Thanks though.