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

24
LINES

< > BotCompany Repo | #1011587 // tailFile (old)

JavaX fragment (include) [tags: archive]

// raise flag to stop
static Flag tailFile(final File file, final int interval, fO onData) {
  final new Flag flag;
  thread "Tail File" {
    long l = 0;
    repeat with ms sleep interval {
      pcall {
        long l2 = l(file);
        if (l2 < l) l = 0;
        if (l2 != l) pcall {
          S text = null;
          pcall {
            text = loadTextFilePart(file, l, l2);
          }
          if (nempty(text))
            callF(onData, text);
          l = l2;
        }
      }
      if (flag.isUp()) break; // break AFTER we checked for new data
    }
  }
  ret flag;
}

Author comment

Began life as a copy of #1006740

download  show line numbers  debug dex  old transpilations   

Travelled to 2 computer(s): cfunsshuasjs, mqqgnosmbjvj

No comments. add comment

Snippet ID: #1011587
Snippet name: tailFile (old)
Eternal ID of this version: #1011587/1
Text MD5: d2de86ed301b6bf2f0f175b8b14a664a
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): Yes
Created/modified: 2017-10-31 18:57:59
Source code size: 605 bytes / 24 lines
Pitched / IR pitched: No / No
Views / Downloads: 249 / 258
Referenced in: [show references]