How close a file opened by java.awt.Desktop

微笑、不失礼 提交于 2019-12-14 03:30:13

问题


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.


回答1:


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.



来源:https://stackoverflow.com/questions/17360106/how-close-a-file-opened-by-java-awt-desktop

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!