Hai,
I am not sure whther u were asking for the same. But what I could undestand is, u were having some problem with reading and writing the data from and to the file ,. U can put the followinf code in a bean and can dyanmically generate the counter value.
The code is as followsimport java.io.*;
class counter
{
public counter() throws IOException
{
try
{
DataInputStream dis=new DataInputStream(new FileInputStream("counter.txt"));
int x=dis.readInt();
x++;
dis.close();
DataOutputStream dos=new DataOutputStream(new FileOutputStream("counter.txt"));
dos.writeInt(x);
dos.close();
System.out.println(x);
}
catch(FileNotFoundException ie)
{
try
{
DataOutputStream dos=new DataOutputStream(new FileOutputStream("counter.txt"));
dos.writeInt(1);
System.out.println("1");
dos.close();
}
catch(Exception ert)
{
System.out.println(ert);
}
}
}
public static void main(
String[] args) throws Exception
{
new counter();
}
}
------------------
Sandeep Jain