Jump to content
xisto Community

abhatia923

Members
  • Content Count

    1
  • Joined

  • Last visited

  1. I am getting access denied to file when execute(compiled successfully) the following applet Please 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);}}
×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.