Initial commit
This commit is contained in:
commit
bfbe536886
59 files changed
+2540
No files matched your search
@@ -0,0 +1,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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user