hi,
your question is too vague...
anyway, this is a random access file example :
try {
File f = new File("filename");
RandomAccessFile raf = new RandomAccessFile(f, "rw");
// Read a character
char ch = raf.readChar();
// Seek to end of file
raf.seek(f.length());
// Append to the end
raf.writeChars("aString");
raf.close();
} catch (IOException e) {
e.printStackTrace();
}
> hi,
>
> i want to roll over the file, that means i want to
> fix the file size (ex:10MB)
This make even less sense than the first question.
When you write to the end of a RandomAccessFile it will automatically increase that files size. You do not have to (in any way shape or form) manually set the files size. If you want to artificially make the file larger than it has to be, write some null bytes to the end of it.
Now, once again, what do you mean by "fix the file size".
You need to do it programatically. i.e. programtically. There is no set method. With each write you need to check the size, and if it will be too large, then you need to shift everything to the front (which will take a while if you do it this way), or better, close the file, rename it, and open a new file (At least this is the way that most self rotating logging algorithms do it.)