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

22
LINES

< > BotCompany Repo | #1036186 // TailFileLinewise [dev.]

JavaX fragment (include)

1  
sclass TailFileLinewise {
2  
  settable File file;
3  
  settable long startOffset;
4  
  settable int interval = 1000;
5  
  
6  
  TailFile tf;
7  
  LineBuffer lineBuffer = new(voidfunc(S s) { newLine(s) });
8  
  
9  
  event newLine(S line);
10  
  
11  
  void start {
12  
    if (tf == null) ret;
13  
    initialFileSize = l(file);
14  
    tf = new TailFile(file, interval, s -> lineBuffer.append(s));
15  
    tf.l = startOffset;
16  
    tf.start();
17  
  }
18  
  
19  
  bool readingHistory() {
20  
    ret tf.currentFileSize() >= initialFileSize;
21  
  }
22  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 1 computer(s): mqqgnosmbjvj

No comments. add comment

Snippet ID: #1036186
Snippet name: TailFileLinewise [dev.]
Eternal ID of this version: #1036186/2
Text MD5: 8f7fd7598f8fda9c7fa5c53d02269d0d
Author: stefan
Category: javax / io
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2022-10-10 16:33:58
Source code size: 504 bytes / 22 lines
Pitched / IR pitched: No / No
Views / Downloads: 130 / 135
Version history: 1 change(s)
Referenced in: [show references]