|
-
Jul 16th, 2005, 08:17 PM
#1
Thread Starter
Member
FileWriter question
I am using a FileWriter in a JApplet class to write to a text file. The text file that I am writing to is first read by a Buffered Reader that gives the data to strings in my application. The reading in process works as expected but when the condition is met that I have set up for the FileWriter to write to the text file I receive this error when I run the Applet in a webbrowser:
java.security.AccessControlException: access denied (java.io.FilePermission C:\Big Walt Productions\Five Word Draw\draw.txt write)
and the file is not written to.
Here is the code I am using for both the FileWriter and Buffered Reader:
FileWriter writer;
BufferedReader buff_hiscore;
/**
* Reads data from text file
*
*/
public void update_highscore()
{
try
{
buff_hiscore = new BufferedReader(new FileReader("C:/Big Walt Productions/Five Word Draw/draw.txt"));
for (int i = 0; i < 2; i++)
{
next_line = buff_hiscore.readLine();
if(i==0)
{
str_highscore_name = next_line;
}
else
{
str_highscore = next_line;
int_highscore = Integer.parseInt(str_highscore);
}
}
buff_hiscore.close();
}
catch(IOException e)
{
}
lbl_highscore_name.setText(str_highscore_name);
lbl_highscore.setText(str_highscore);
}
public void high_score_check()
{
try
{
writer = new FileWriter("C:/Big Walt Productions/Five Word Draw/draw.txt");
if(int_score > int_highscore)
{
for(int i= 0; i < 2; i++)
{
if(i==0)
{
writer.write(str_playername);
}
else
{
writer.write(str_score);
}
}
}
writer.close();
}
catch(IOException e)
{
}
int_highscore = int_score;
lbl_highscore_name.setText(str_playername);
lbl_highscore.setText(str_score);
}
Can someone please help me with this problem?
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|