bob-cac
bob-cac

Reputation: 1302

File observer using java

I am using watch Service in order to track changes made to a file and print these changes in a text area. suppose only new data will be written(no delete and no replace) to this file is there a way to get this new data without the need to rewrite the over all file when changes done.

Upvotes: 0

Views: 222

Answers (1)

Dan Putman
Dan Putman

Reputation: 48

The Watch Service isn't able to tell what changed about a file. Assuming you have access to the old content of the file, you could use a diff library like java-diff-utils to find the changes. Example 1 on their wiki should match up with your issue.

Check out

Upvotes: 1

Related Questions