FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
scribe-java/src/main/java/org/scribe/utils/StreamUtils.java at master · entrobe/scribe-java · GitHub
entrobe
/
scribe-java
Public
forked from
scribejava/scribejava
Notifications
You must be signed in to change notification settings
Fork
0
Star
0
Code
Pull requests
0
Actions
Projects
Wiki
Security and quality
0
Insights
Additional navigation options
Code
Pull requests
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
scribe-java
/
src
/
main
/
java
/
org
/
scribe
/
utils
/
StreamUtils.java
Copy path
More file actions
More file actions
Latest commit
History
History
History
42 lines (40 loc) · 945 Bytes
Breadcrumbs
scribe-java
/
src
/
main
/
java
/
org
/
scribe
/
utils
/
StreamUtils.java
Copy path
File metadata and controls
42 lines (40 loc) · 945 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
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
33
34
35
36
37
38
39
40
41
42
package
org
.
scribe
.
utils
;
import
java
.
io
.*;
/**
* Utils to deal with Streams.
*
* @author Pablo Fernandez
*/
public
class
StreamUtils
{
/**
* Returns the stream contents as an UTF-8 encoded string
*
* @param is input stream
* @return string contents
*/
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
IllegalStateException
(
"Error while reading response body"
,
ioe
);
}
}
}
Back
|
FazBrowse Home
|
New Git URL