So you want something to happen once you open the file in a text editor (or some other application, you didn't provide details about that - is it a
Java application?); is that correct? If so, I don't see where Java enters the picture, since, as I said before, files don't have a concept of a cursor - applications do.