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

16
LINES

< > BotCompany Repo | #1009574 // LinesBuffer - text stream to lines

JavaX fragment (include)

sclass LinesBuffer {
  new L<S> completeLines;
  S currentLine = "";
  
  void append(S s) {
    currentLine += s;
    int i;
    while ((i = currentLine.indexOf('\n')) >= 0) {
      // inefficient
      completeLines.add(dropTrailingBackslashR(substring(currentLine, 0, i)));
      currentLine = substring(currentLine, i+1);
    }
  }
  
  L<S> getAndClearCompleteLines() { ret cloneAndClearList(completeLines); }
}

Author comment

Began life as a copy of #1007086

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: #1009574
Snippet name: LinesBuffer - text stream to lines
Eternal ID of this version: #1009574/2
Text MD5: ae21c7de900bb98a96ac29f6d1c73ade
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-08-08 17:11:39
Source code size: 431 bytes / 16 lines
Pitched / IR pitched: No / No
Views / Downloads: 459 / 1069
Version history: 1 change(s)
Referenced in: [show references]