abhatia923 0 Report post Posted July 16, 2010 (edited) I am getting access denied to file when execute(compiled successfully) the following appletPlease help: import java.io.*;import java.applet.*;import java.awt.*;public class counterApplet extends Applet{ public static int i=0; public static String no=""; public static String pre="You Are Visitor Number: "; public static String p=""; public void init(){ FileInputStream file=null; try {file = new FileInputStream("counter");} catch(FileNotFoundException e) {System.exit(1);} //load value and increment it try{for(i=0;i!=10;) {i=(file.read());if(i==-1) {break;} else{no=no+(char)i;}} i = Integer.parseInt(no)+1;}catch(Exception e){System.exit(1);} //write new value no=""+i; BufferedOutputStream bu = null; try { bu= new BufferedOutputStream(new FileOutputStream("counter")); bu.write(no.getBytes());}catch (FileNotFoundException ex) {ex.printStackTrace();} catch (IOException ex) {ex.printStackTrace();} finally { try { if (bu != null) { bu.flush(); bu.close();} } catch (IOException ex) { ex.printStackTrace(); } } } public void start(){} public void paint(Graphics g){ p=pre+no; g.drawString(p,20,30);}} Edited July 16, 2010 by yordan Please do not forget the "code" tags when posting some pieces of code. (see edit history) Share this post Link to post Share on other sites
bendr 0 Report post Posted July 18, 2010 If you think about where applets execute, you will find that a counter makes no sense. Share this post Link to post Share on other sites