简体   繁体   English

FileHandler Java与Windows

[英]FileHandler Java with Windows

I am trying to write an Application which lists down the files from the server . 我正在尝试编写一个应用程序,它列出了服务器中的文件。 Now I want to give users to open any file from the list (Windows) with any editor for example a text file and User opens with NotePad++. 现在,我想让用户使用任何编辑器(例如文本文件)打开列表(Windows)中的任何文件,并使用NotePad ++打开用户。

Now is there anyway I can know that if user saves the file,if yes, then I would upload the file back to the server. 无论如何我现在知道如果用户保存文件,如果是,那么我会将文件上传回服务器。

使用File#lastModified()获取最后修改文件的时间。

There is a tutorial about Watching a Directory for Changes describing the WatchService which was introduced in Java 7. You can use this service to monitor files and directories: 有一个关于监视 更改目录的教程, 该目录描述了Java 7中引入的WatchService 。您可以使用此服务来监视文件和目录:

WatchService watcher = FileSystems.getDefault().newWatchService();
Path dir = ...;
try {
    WatchKey key = dir.register(watcher,
                           StandardWatchEventKinds.ENTRY_CREATE,
                           StandardWatchEventKinds.ENTRY_DELETE,
                           StandardWatchEventKinds.ENTRY_MODIFY);
} catch (IOException x) {
    System.err.println(x);
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM