How close a file opened by java.awt.Desktop

2019-09-26 06:07发布

How to close an opened excel file?

Open excel code is:

File file = new File("e:\\aaa.xlsx");
Desktop desktop = Desktop.getDesktop();
desktop.open(file);

What would be the close code?

just using java open and close Windows application like use mouse.

标签: java file awt
1条回答
迷人小祖宗
2楼-- · 2019-09-26 06:41

Forget it. Open here means that the registered application, Excel, takes over and opens a Window. After that you have no control, but watching. Excel will close.

File is a class that represents a file system path. Itself it has no state of associated reader/writer. Java 7 now parallel introduces a more evolved class Path. Besides (obviously) the path on the file system, it also stores what file system. With Path one can have more than one FileSystem, like a ZipFileSystem. That allows you to copy and rename files in a zip.

That was just an elaboration.

查看更多
登录 后发表回答