How to watch file for new content and retrieve that content
I have a file with name foo.txt . This file contains some text. I want to achieve following functionality: I launch program write something to the file (for example add one row: new string in foo.txt ) I want to get ONLY NEW content of this file. Can you clarify the best solution of this problem? Also I want resolve related issues: in case if I modify foo.txt I want to see diff. The closest tool which I found in Java is WatchService but if I understood right this tool can only detect type of event happened on filesystem (create file or delete or modify). Java Diff Utils is designed for that