How to Wait for windows process to finish before opening file in java

后端 未结 3 720
伪装坚强ぢ
伪装坚强ぢ 2021-01-19 21:51

I have a implemented a listener that notifies if we receive a new file in a particular directory. This is implemented by polling and using a TimerTask. Now the program is s

3条回答
  •  野的像风
    2021-01-19 22:37

    I think you can create the File object and then use canRead or canWrite to know whether file ready to be used by the other java program.

    http://docs.oracle.com/javase/6/docs/api/java/io/File.html

    Other option is to try to Open file on first program and if it throws the exception then dont call the other java program. But I ll recommend the above 'File option.

提交回复
热议问题