Jump to content

Access denied(java.io.FilePermission bal.txt write)

- - - - -

This topic has been archived. This means that you cannot reply to this topic.
1 reply to this topic

#1
kimerajamm

kimerajamm

    Newbie

  • Members
  • Pip
  • 3 posts
Ok, I am trying to make a simple program that will calculate your account balance and save it as a text file called bal.txt, but i am getting an error that says "access denied(java.io.FilePermission bal.txt write)" the part of my code that i am having problems with is

Quote

try{
FileWriter fstream = new FileWriter(new File("bal.txt")};
BufferedWriter out = new BufferedWriter(fstream);
out.write(l10.getText());
}
catch(Exception e){
l10.setText("File error: " + e.getMessage());
}
Any suggestions?
p.s. i am fairly new to java, if you can't tell




___________________
short sale company
Virginia Retirement Communities
Spam Links deleted

#2
wim DC

wim DC

    Writes binary right handed and hex left handed

  • Members
  • PipPipPipPipPipPipPipPipPip
  • 2,084 posts
I think it isn't really a Java issue here but your OS that doesn't allow the program to write files. If it's windows, try to run as administrator or to write somewhere else than the C: drive.

(Note that it's best to close the stream using .close() in the end. To this this, you can put the following after the catch part:

finally{

  out.close();

}