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

16
LINES

< > BotCompany Repo | #1007086 // LastLineBuffer - holds last line of a text stream

JavaX fragment (include)

1  
sclass LastLineBuffer {
2  
  int lineCount;
3  
  S lastLine, currentLine = "";
4  
  
5  
  void append(S s) {
6  
    currentLine += s;
7  
    int i;
8  
    while ((i = currentLine.indexOf('\n')) >= 0) {
9  
      // inefficient
10  
      lastLine = dropTrailingBackslashR(substring(currentLine, 0, i));
11  
      currentLine = substring(currentLine, i+1);
12  
    }
13  
  }
14  
  
15  
  S lastCompleteLine() { ret lastLine; }
16  
}

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1007086
Snippet name: LastLineBuffer - holds last line of a text stream
Eternal ID of this version: #1007086/3
Text MD5: 004aebaff0e6e5417d974712acb341b4
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-03-02 22:02:16
Source code size: 392 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 556 / 1203
Version history: 2 change(s)
Referenced in: [show references]