I tried writing a new record to db.db file once and the write was succesful. If I continue to write to the same record the writes are successful. But when I try writing to another record, somehow I get a bunch of garbage in my db.db file. There may be an obvious reason for this, but because I haven't done any File I/O before this project, I don't have a clue why this would be happening. Any suggestions will be appreciated. (j.l. edited subject) [ October 14, 2002: Message edited by: Junilu Lacar ]
Ronnie, It's hard to judge without seeing the code, but you may not be resetting your filepointer properly. All best, M, author The Sun Certified Java Developer Exam with J2SE 1.4 [ October 14, 2002: Message edited by: Max Habibi ]
Max, I'll check my file pointer and see if that's the problem. If I'm setting my file pointer wrong, shouldn't it just write at the wrong position. Why would there be garbage at the header?
town drunk ( and author)
Joined: Jun 27, 2002
Originally posted by Ronnie Phelps: Max, I'll check my file pointer and see if that's the problem. If I'm setting my file pointer wrong, shouldn't it just write at the wrong position. Why would there be garbage at the header?
I don't know what's up with the FileOutputStream. I had to specify a mode before the size of the output stream changed from zero. But either way it looked as though it was appending whether I set append mode or not. Anyway, I used a RandomAccessFile and everything works okay. By the way I'm still not done with this beta exam. I don't plan to pass but at least I know that the exam is in arms reach now and when I pay for the exam my company will reimburse me anyway. So I'm gonna finish up in the next two hours just so I can have the oppurtunity take the follow up exam and use it as a learning experience.