Java 8 WatchService - top ranked examples from Open Source projects

These code examples were ranked by Codota’s semantic indexing as the best open source examples for Java 8 WatchService class.

This code example shows how to use the following methods:close
        } 
    } 
 
    public void close() throws IOException {
        if (watcher != null) {
            watcher.close();
        } 
    } 
 
    public long getLastModified() { 
        return lastModified;
    } 
 
    // Properties 
    //------------------------------------------------------------------------- 
 
 
    public void setRootPath(String rootPath) {
        Path path = new File(rootPath).getAbsoluteFile().toPath();
        setRoot(path);
4
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close
    } 
  } 
 
  public void done() { 
    try { 
      watcher.close();
    } 
    catch (IOException ignored) {}
  } 
 
//  static void usage() { 
//    System.err.println("usage: java WatchDir [-r] dir"); 
//    System.exit(-1); 
//  } 
// 
//  public static void main(String[] args) throws IOException { 
//    // parse arguments 
//    if (args.length == 0 || args.length > 2) usage(); 
//    boolean recursive = false; 
//    int dirArg = 0; 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:close
		} 
	} 
 
	protected void stopWatchService() { 
		try { 
			watchService.close();
		} catch (IOException e) {
			logger.warn("Cannot deactivate folder watcher", e);
		} 
 
		watchService = null;
	} 
 
	/** 
	 *  
	 * @param watchService 
	 * @param toWatch 
	 * @return 
	 */ 
	protected abstract AbstractWatchQueueReader buildWatchQueueReader( 
3
CodeRank
Experience pair programming with AI  Get Codota for Java
This code example shows how to use the following methods:poll
  public void testOpenWatchServicesClosed() throws IOException {
    WatchService ws1 = fs.newWatchService();
    WatchService ws2 = fs.newWatchService();
 
    assertNull(ws1.poll());
    assertNull(ws2.poll());
 
    fs.close();
 
    try { 
      ws1.poll();
      fail(); 
    } catch (ClosedWatchServiceException expected) {
    } 
 
    try { 
      ws2.poll();
      fail(); 
    } catch (ClosedWatchServiceException expected) {
    } 

3
CodeRank
Experience pair programming with AI  Get Codota for Java
See Code Examples for Java 8 WatchService Methods: