Java HTTP Response getResponseMessage(InputStream inputStream, HttpURLConnection connection)

Here you can find the source of getResponseMessage(InputStream inputStream, HttpURLConnection connection)

Description

get Response Message

License

Apache License

Declaration

private static String getResponseMessage(InputStream inputStream, HttpURLConnection connection)
            throws UnsupportedEncodingException, IOException 

Method Source Code


//package com.java2s;
//License from project: Apache License 

import java.io.IOException;
import java.io.InputStream;

import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;

public class Main {
    private static String getResponseMessage(InputStream inputStream, HttpURLConnection connection)
            throws UnsupportedEncodingException, IOException {
        String responseMessage = null;
        StringBuffer sb = new StringBuffer();
        InputStream dis = connection.getInputStream();
        int chr;// w  w w.ja  v  a 2  s  .c om
        while ((chr = dis.read()) != -1) {
            sb.append((char) chr);
        }
        if (sb != null) {
            responseMessage = sb.toString();
        }
        return responseMessage;
    }
}

Related

  1. getResponseContent(String url)
  2. getResponseErrorContent(HttpURLConnection httpConn)
  3. getResponseHeader(HttpURLConnection conn)
  4. getResponseHeader(String headerName, HttpURLConnection urlConnection)
  5. getResponseHeaders(URLConnection conn, HashMap headers)
  6. getResponseStream(final HttpURLConnection connection)
  7. getResponseStream(HttpURLConnection conn)
  8. getResponseStringFromConn(HttpURLConnection conn, boolean isSuccess)
  9. getResponseText(URL constructedUrl, String encoding)