List of utility methods to do HTTP Response
String | readResponse(HttpURLConnection conn, String encoding) read Response StringBuffer sb = new StringBuffer(); BufferedReader br = null; try { InputStream in = conn.getInputStream(); br = new BufferedReader(new InputStreamReader(in)); String line = ""; while ((line = br.readLine()) != null) { sb.append(line); ... |
byte[] | readResponse(HttpURLConnection connection) read Response boolean error = connection.getResponseCode() >= 400; try (ByteArrayOutputStream byteArrayOutputStream = new ByteArrayOutputStream(); InputStream inputStream = (!error) ? connection.getInputStream() : connection.getErrorStream()) { byte[] chunk = new byte[CHUNK_SIZE]; int i; while ((i = inputStream.read(chunk)) > 0) { byteArrayOutputStream.write(chunk, 0, i); return byteArrayOutputStream.toByteArray(); |
String | readResponse(HttpURLConnection httpURLConnection) read Response InputStream inputStream = null; BufferedReader bufferedReader = null; try { StringBuilder stringBuilder = new StringBuilder(); int responseCode = httpURLConnection.getResponseCode(); if (responseCode / 100 == 2) { inputStream = httpURLConnection.getInputStream(); } else { ... |
String | readResponse(URLConnection conn) read Response BufferedReader in; StringBuffer response = new StringBuffer(); String line; try { in = new BufferedReader(new InputStreamReader(conn.getInputStream())); } catch (Exception ex) { InputStream err = ((HttpURLConnection) conn).getErrorStream(); if (err == null) { ... |