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)

static void onNewFileInDir(final File dir, final VF1<File> onNewFile) {
  onNewFileInDir(dir, 1.0, onNewFile);
}

static void onNewFileInDir(final File dir, double interval, final VF1<File> onNewFile) {
  doEvery(interval, new Runnable {
    Set<File> files = asHashSet(listFiles(dir));
    
    public void run {
      File[] newFiles = listFiles(dir);
      for (File f : newFiles)
        if (!files.contains(f))
          pcallF(onNewFile, f);
      files = asHashSet(newFiles);
    }
  });
}

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: 357 / 386
Version history: 4 change(s)
Referenced in: [show references]