dcsimg

How can I open the same file for reading as well as writing?

John Zukowski

The RandomAccessFile class supports simultanous reading and writing from the same file. Just open it in "rw" mode:

RandomAccessFile raf = 
    new RandomAccessFile("filename.txt", "rw");
Use skipBytes() to move to where you wish to read/write.