MCPcopy Index your code
hub / github.com/OpenFeign/feign / toString

Method toString

core/src/main/java/feign/Util.java:236–254  ·  view source on GitHub ↗

Adapted from com.google.common.io.CharStreams.toString().

(Reader reader)

Source from the content-addressed store, hash-verified

234
235 /** Adapted from {@code com.google.common.io.CharStreams.toString()}. */
236 public static String toString(Reader reader) throws IOException {
237 if (reader == null) {
238 return null;
239 }
240 try {
241 StringBuilder to = new StringBuilder();
242 CharBuffer charBuf = CharBuffer.allocate(BUF_SIZE);
243 // must cast to super class Buffer otherwise break when running with java 11
244 Buffer buf = charBuf;
245 while (reader.read(charBuf) != -1) {
246 buf.flip();
247 to.append(charBuf);
248 buf.clear();
249 }
250 return to.toString();
251 } finally {
252 ensureClosed(reader);
253 }
254 }
255
256 /** Adapted from {@code com.google.common.io.ByteStreams.toByteArray()}. */
257 public static byte[] toByteArray(InputStream in) throws IOException {

Calls 3

ensureClosedMethod · 0.95
readMethod · 0.45
appendMethod · 0.45