Not logged in.  Login/Logout/Register | List snippets | | Create snippet | Upload image | Upload data

17
LINES

< > BotCompany Repo | #1015314 // onNewFileInDir - interval = seconds

JavaX fragment (include)

1  
static void onNewFileInDir(final File dir, final VF1<File> onNewFile) {
2  
  onNewFileInDir(dir, 1.0, onNewFile);
3  
}
4  
5  
static void onNewFileInDir(final File dir, double interval, final VF1<File> onNewFile) {
6  
  doEvery(interval, new Runnable {
7  
    Set<File> files = asHashSet(listFiles(dir));
8  
    
9  
    public void run {
10  
      File[] newFiles = listFiles(dir);
11  
      for (File f : newFiles)
12  
        if (!files.contains(f))
13  
          pcallF(onNewFile, f);
14  
      files = asHashSet(newFiles);
15  
    }
16  
  });
17  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 13 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tslmcundralx, tvejysmllsmz, vouqrxazstgt

No comments. add comment

Snippet ID: #1015314
Snippet name: onNewFileInDir - interval = seconds
Eternal ID of this version: #1015314/5
Text MD5: 01f4f922bfebc0ef21176553f5aa9674
Author: stefan
Category: javax / io
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2018-05-12 21:34:43
Source code size: 512 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 362 / 391
Version history: 4 change(s)
Referenced in: [show references]