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   

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

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: 188 / 184
Version history: 1 change(s)
Referenced in: [show references]

Formerly at http://tinybrain.de/1012290 & http://1012290.tinybrain.de