The problem with Linux and Unix is that they don't lock files like Windows does. While Windows will surely complain if you try to remove a file that's still opened by some application, Linux and Unix will delete it without a problem.
Apart from using temporary files like Jeff described, you can also create temporary utility files. I've seen applications that create an
A.txt.lck file for the time the file should be locked, then delete this temporary file when done. While this file exist the user side should not touch the
A.txt file. Using a WatchService (since
Java 7) can even help you get notified when the
.lck file is deleted.