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

14
LINES

< > BotCompany Repo | #1027355 // drainStreamToPrint_charByChar_onChar_onLine

JavaX fragment (include)

1  
svoid drainStreamToPrint_charByChar_onChar_onLine(InputStream stream, IF0<Bool> enabled, IVF1<Char> onChar, IVF1<S> onLine) ctex {
2  
  InputStreamReader in = new(stream);
3  
  new StringBuilder buf;
4  
  int c;
5  
  while ((c = in.read()) >= 0) {
6  
    if (enabled == null || enabled!) {
7  
      S s = str((char) c);
8  
      print_noNewLine(s);
9  
      callF(onChar, (char) c);
10  
      buf.append(s);
11  
      if (c == '\n') callF(onLine, getAndClearStringBuilder(buf));
12  
    }
13  
  }
14  
}

Author comment

Began life as a copy of #1027354

download  show line numbers  debug dex  old transpilations   

Travelled to 7 computer(s): bhatertpkbcr, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv

No comments. add comment

Snippet ID: #1027355
Snippet name: drainStreamToPrint_charByChar_onChar_onLine
Eternal ID of this version: #1027355/1
Text MD5: c299dd74d782c4d75115f5f5e06d6f2b
Author: stefan
Category: javax / io
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2020-03-11 15:53:21
Source code size: 471 bytes / 14 lines
Pitched / IR pitched: No / No
Views / Downloads: 162 / 189
Referenced in: [show references]