Use a RandomAccessFile. This has already been covered on SO I believe.
java file input with rewind()/reset() capability
Basically you'd just seek to the starting point, write however many bytes you want to from there, and remember the point you stopped writing from.