Dafly
Oct 29th, 2000, 09:31 PM
I keep getting an error saying exception: com.ms.security.SecurityExceptionEx[counterApp.init]cannot access file Vist.cnt
if you need to make a Vist.cnt file all it is is a text file with any numbers like 1495
import java.applet.Applet;
import java.awt.*;
import java.io.*;
public class counterApp extends Applet {
int Visits;
String HldVis;
public void init() {
HldVis = "";
try{
FileInputStream Fis = new
FileInputStream("Vist.cnt");
DataInputStream myInput =
new DataInputStream(Fis);
while (myInput.available() !=0)
{
HldVis = myInput.readLine();
String.valueOf(HldVis);
}
myInput.close();
}
catch (Exception e)
{
}
try{
FileOutputStream fos = new FileOutputStream("Vist.cnt");
PrintStream myOutput = new PrintStream(fos);
int Visits = Integer.parseInt(HldVis);
Visits++;
myOutput.print(Visits);
myOutput.close();
System.out.println("Hello");
//repaint();
}
catch (IOException e)
{
System.exit(1);
}
}
public void paint(Graphics g) {
g.setColor(Color.red);
g.drawString(String.valueOf(Visits), 50, 10);
}
}
Thanx,
Jeremy
If its as simple as it seems then I am not basic enough.
if you need to make a Vist.cnt file all it is is a text file with any numbers like 1495
import java.applet.Applet;
import java.awt.*;
import java.io.*;
public class counterApp extends Applet {
int Visits;
String HldVis;
public void init() {
HldVis = "";
try{
FileInputStream Fis = new
FileInputStream("Vist.cnt");
DataInputStream myInput =
new DataInputStream(Fis);
while (myInput.available() !=0)
{
HldVis = myInput.readLine();
String.valueOf(HldVis);
}
myInput.close();
}
catch (Exception e)
{
}
try{
FileOutputStream fos = new FileOutputStream("Vist.cnt");
PrintStream myOutput = new PrintStream(fos);
int Visits = Integer.parseInt(HldVis);
Visits++;
myOutput.print(Visits);
myOutput.close();
System.out.println("Hello");
//repaint();
}
catch (IOException e)
{
System.exit(1);
}
}
public void paint(Graphics g) {
g.setColor(Color.red);
g.drawString(String.valueOf(Visits), 50, 10);
}
}
Thanx,
Jeremy
If its as simple as it seems then I am not basic enough.