Well, you could try using FileChannel's tryLock() to obtain a lock on the file before you read it. If it returns null, that would mean another process has a lock on the file. You can use lock() to wait until the lock is available, or you can sleep or do something else. This isn't guaranteed to work, but it's worth a try. It's possible that the other process ignores or circumvents locking; it's also possible that it just continues to hold on to the lock it has.
Another option might be to use File's renameTo() to attempt to move the file to another directory. This is generally a nice atomic operation. If it fails, that may indicate that the other process is currently writing to the file. If it succeeds, you can be pretty sure that the process is no longer writing to that file, as it's now relocated. The process should now create a new file at the old location, to add its new content. This only works if it's acceptable for the file to be moved and broken up into parts; I have no idea if that applies to your situation.
Otherwise, you may simply have to write your
Java code to allow for the possibility that the file is currently being written to. The last line of the file should always be regarded as potentially incomplete. Perhaps
you should always delay processing the last line until the next update, when additional lines arrive.