forked from scribejava/scribejava
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathStreamUtils.java
More file actions
32 lines (29 loc) · 735 Bytes
/
Copy pathStreamUtils.java
File metadata and controls
32 lines (29 loc) · 735 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
package org.scribe.utils;
import java.io.*;
public class StreamUtils
{
public static String getStreamContents(InputStream is)
{
Preconditions.checkNotNull(is, "Cannot get String from a null object");
try
{
final char[] buffer = new char[0x10000];
StringBuilder out = new StringBuilder();
Reader in = new InputStreamReader(is, "UTF-8");
int read;
do
{
read = in.read(buffer, 0, buffer.length);
if (read > 0)
{
out.append(buffer, 0, read);
}
} while (read >= 0);
in.close();
return out.toString();
} catch (IOException ioe)
{
throw new RuntimeException("Error while reading response body", ioe);
}
}
}