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

18
LINES

< > BotCompany Repo | #1008169 // readerToString - fully read from Reader into string and close it

JavaX fragment (include)

1  
static S readerToString(Reader r) ctex {
2  
  if (r == null) null;
3  
  try {
4  
    new StringBuilder buf;
5  
    int n = 0;
6  
    while (true) {
7  
      int ch = r.read();
8  
      if (ch < 0)
9  
        break;
10  
      buf.append((char) ch);
11  
      ++n;
12  
      //if ((n % loadPage_verboseness) == 0) print("  " + n + " chars read");
13  
    }
14  
    ret buf.toString();
15  
  } finally {
16  
    r.close();
17  
  }  
18  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 19 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mowyntqkapby, mqqgnosmbjvj, ofpaelxlmzfo, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, qsqiayxyrbia, tslmcundralx, tvejysmllsmz, vouqrxazstgt, whxojlpjdney, xrpafgyirdlv

No comments. add comment

Snippet ID: #1008169
Snippet name: readerToString - fully read from Reader into string and close it
Eternal ID of this version: #1008169/3
Text MD5: f1714e2acf69335ca0a267f49ac5f994
Author: stefan
Category: javax / i.o.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2021-06-04 23:18:04
Source code size: 392 bytes / 18 lines
Pitched / IR pitched: No / No
Views / Downloads: 570 / 1979
Version history: 2 change(s)
Referenced in: [show references]