I haven't used RAF, but I very much doubt that it can deal with backspace characters - it's not a console or text editor, after all.
If you want to put a different character at the start of line 2 you need to set the file pointer to that position (using seek), and then you can start overwriting. [ February 25, 2008: Message edited by: Ulf Dittmer ]
Yes but the only problem with that is that it needs to be the EXACT number of characters. If it's one of too little then there's some characters left over. And if there's too many then it overwrites line 3
Yes, unfortunately RAF really isn't good for this sort of thing. If you want to replace one region with another string with a different length, you need to shift all the subsequent bytes in the file to accommodate the new length. There's no simple method call to do that, and it's a fairly ineffecient process - especially if you still plan to edit the file more afterwards.
Generally if you want to do this sort of thing, you'd be better off keeping the file in memory as, say, an ArrayList if String objects, each one representing one line. Or perhaps a LinkedList, or perhaps containing StringBuilder objects instead of Strings. Make your changes to the objects in memory, and then, when you're done with all the changes, write a new file, probably using PrintWriter. (Or if you're on a JDK prior to JDK 5, using a PrintWriter wrapped in a BufferefWriter wrapped in a FileWriter - blech.)
Incidentally, having an empty catch block there is a very bad idea, even in a practice program. If anything at all goes wrong, you will hide the error and waste time because you can't see what happened. Putting a simple e.printStackTrace() in the catch block can save you a lot of time later.
"I'm not back." - Bill Harding, Twister
subject: RandomAccessFile: backspacing and inserting