小编Tib*_*scu的帖子

如何只从线程写入一次文件?

我想在每次修改文件时写一些东西到文件的末尾,我正在使用这段代码:

public class Main {

    public static final String DIRECTORY_TO_WATCH = "D:\\test";

    public static void main(String[] args) {
        Path toWatch = Paths.get(DIRECTORY_TO_WATCH);
        if (toWatch == null) {
            throw new UnsupportedOperationException();
        }
        try {
            WatchService myWatcher = toWatch.getFileSystem().newWatchService();
            FileWatcher fileWatcher = new FileWatcher(myWatcher);
            Thread t = new Thread(fileWatcher, "FileWatcher");
            t.start();
            toWatch.register(myWatcher, StandardWatchEventKinds.ENTRY_MODIFY);
            t.join();
        } catch (IOException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InterruptedException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        }

    }
}
Run Code Online (Sandbox Code Playgroud)

和线程类:

public class …
Run Code Online (Sandbox Code Playgroud)

java multithreading

6
推荐指数
1
解决办法
280
查看次数

CVS存储库缺少连接类型

我是新手使用CVS存储库.我正在尝试通过右键单击CVS存储库区域,New - > Repository Location来导入repo,然后弹出一个带有Add CVS存储库的窗口.在连接类型下,在eclipse luna中我有'extssh',但在eclipse mars中我只有'ext'和'pserver'.我需要使用extssh.它是什么以及如何配置它?

eclipse cvs

5
推荐指数
1
解决办法
2168
查看次数

标签 统计

cvs ×1

eclipse ×1

java ×1

multithreading ×1