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

15
LINES

< > BotCompany Repo | #1012290 // hijackPrint_tee - hijack the print function for a function call, return printed contents, also print normally

JavaX fragment (include)

static S hijackPrint_tee(Runnable r) {
  final new StringBuilder buf;
  O old = interceptPrintInThisThread(new F1<S, Bool>() {
    Bool get(S s) {
      buf.append(s);
      true;
    }
  });
  try {
    callF(r);
    ret str(buf);
  } finally {
    interceptPrintInThisThread(old);
  }
}

Author comment

Began life as a copy of #1011313

download  show line numbers  debug dex  old transpilations   

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

No comments. add comment

Snippet ID: #1012290
Snippet name: hijackPrint_tee - hijack the print function for a function call, return printed contents, also print normally
Eternal ID of this version: #1012290/2
Text MD5: 9b7ff48b1303b38cbd03e9ae58c57bad
Author: stefan
Category: javax
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-11-27 12:47:59
Source code size: 302 bytes / 15 lines
Pitched / IR pitched: No / No
Views / Downloads: 350 / 382
Version history: 1 change(s)
Referenced in: [show references]