public class Response extends Object implements AutoCloseable
| Constructor and Description |
|---|
Response(HttpURLConnection connection,
InputStream dataStream,
int statusCode,
String contentEncoding,
String contentType,
Map<String,String> headerFields) |
| Modifier and Type | Method and Description |
|---|---|
void |
close() |
String |
getContentEncoding() |
String |
getContentType() |
String |
getHeaderField(String name) |
Map<String,String> |
getHeaderFields() |
int |
getStatusCode() |
InputStream |
getStream() |
byte[] |
getStreamAsBytearray()
Converts the inputstream to a string in UTF-8.
|
String |
getStreamAsString()
Converts the inputstream to a string in UTF-8.
|
String |
getStreamAsString(Charset charset)
Converts the inputstream to a string with the given encoding.
|
String |
getStreamAsString(String encoding)
Converts the inputstream to a string with the given encoding.
|
boolean |
isClientError()
Returns true if the http status code is between 400 and 499
|
boolean |
isFailed()
Returns true if the http status code is not between 200 and 299
|
boolean |
isInformational()
Returns true if the http status code is not between 100 and 199
|
boolean |
isRedirection()
Returns true if the http status code is between 300 and 399
|
boolean |
isServerError()
Returns true if the http status code is between 500 and 599
|
boolean |
isSucceded()
Returns true if the http status code is between 200 and 299
|
void |
storeStream(File file) |
void |
storeStream(File file,
boolean gunzip) |
public Response(HttpURLConnection connection, InputStream dataStream, int statusCode, String contentEncoding, String contentType, Map<String,String> headerFields)
public InputStream getStream()
public byte[] getStreamAsBytearray()
throws IOException
IOExceptionpublic String getStreamAsString() throws IOException
IOExceptionpublic String getStreamAsString(Charset charset) throws IOException
IOExceptionpublic String getStreamAsString(String encoding) throws IOException
IOExceptionpublic void storeStream(File file) throws FileNotFoundException, IOException
FileNotFoundExceptionIOExceptionpublic void storeStream(File file, boolean gunzip) throws FileNotFoundException, IOException
FileNotFoundExceptionIOExceptionpublic int getStatusCode()
public String getContentEncoding()
public String getContentType()
public boolean isFailed()
public boolean isInformational()
public boolean isSucceded()
public boolean isRedirection()
public boolean isClientError()
public boolean isServerError()
public void close()
close in interface AutoCloseableCopyright © 2017. All rights reserved.