How do I use one Java program, to monitor another Java program's output?

后端 未结 3 1681
一整个雨季
一整个雨季 2021-01-01 08:03

Below is diagram that shows what I\'m trying to do : it is just 2 programs. One is a simple Child program that writes out integers every 2 seconds, line-by-line

3条回答
  •  自闭症患者
    2021-01-01 08:18

    You can use the directory watch service:

    https://docs.oracle.com/javase/tutorial/essential/io/notification.html

    You can configure a path or a file and register a watcher.

    The watcher gets a notification every time a file is changed. You can store this timestamp of a notification for later use.

    For details see my link above.

    You may then use a Timer or a Thread to check last modification.

提交回复
热议问题