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

17
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  
  try {
3  
    new StringBuilder buf;
4  
    int n = 0;
5  
    while (true) {
6  
      int ch = r.read();
7  
      if (ch < 0)
8  
        break;
9  
      buf.append((char) ch);
10  
      ++n;
11  
      //if ((n % loadPage_verboseness) == 0) print("  " + n + " chars read");
12  
    }
13  
    ret buf.toString();
14  
  } finally {
15  
    r.close();
16  
  }  
17  
}

download  show line numbers  debug dex  old transpilations   

Travelled to 17 computer(s): aoiabmzegqzx, bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, ofpaelxlmzfo, onxytkatvevr, pyentgdyhuwx, pzhvpgtvlbxg, qsqiayxyrbia, tslmcundralx, tvejysmllsmz, 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/2
Text MD5: 45b6e4a238f57d8c6793119c5bec562f
Author: stefan
Category: javax / i.o.
Type: JavaX fragment (include)
Public (visible to everyone): Yes
Archived (hidden from active list): No
Created/modified: 2017-04-29 16:51:03
Source code size: 368 bytes / 17 lines
Pitched / IR pitched: No / No
Views / Downloads: 312 / 1562
Version history: 1 change(s)
Referenced in: [show references]

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