Skip to Main Content

Java Programming

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Multiple processes reading/writing in the same file

807580Jun 22 2010 — edited Jun 22 2010
Hi people!

Wrote a little java-program which reads after errors in a file, AND at the same time, another program is writing to the same file.
The writing-part writes to the file whenever it got a string, the string contains information about events that occurs in some system and
the information-string ends with a new-line ("\n"). The "reading-program" copies the file, saves it in a temporary directory
and scans after errors in the copied file. Afterwards it's done scanning after errors, the "reading-program" saves where it last read
in the file in a database and deletes the copied file. The next time the "reading-program" starts, it starts scanning after errors at
the last-location-read-in-the-file - variable to not read the same crap over and over again.

Here is the problem, sometimes when my "reading-program" is scanning after new errors at the last-location-read-in-the-file,
it stands in the middle of a information-string which is not supposed to. Does it have something to do with that multiple
processes are reading/writing in the file so the data in the file are being corrupted for some reason?

Thanks in advance
// Razz
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jul 20 2010
Added on Jun 22 2010
16 comments
2,549 views