Search code examples
javafile-ioawtprocessbuildermongo-java

How to get file close event using java


My application saves excel file data in a database (mongodb) using java.

On user click my application will do

  • First create an excel file on local filesystem for instance C:\ali.xlsx and place data on excel file .
  • Open excel file C:\ali.xlsx using java.awt.Desktop class open method for the cross platform perspective.
  • When user close file C:\ali.xlsx gets its close event so that i will get file updated value and save it to the database.

  • Delete the file C:\ali.xlsx from the local filesystem.

My Question :
How to implement the third bullet point.
In short : how to get close event of any file using java.


If anyone have another approach to implement this functionality please tell me also that's why I write the application flow .


Solution

  • I don't know any straightforward way, the uphill (:-)) way would be: