Here you can find the source of getResponseErrorContent(HttpURLConnection httpConn)
Parameter | Description |
---|---|
httpConn | a parameter |
Parameter | Description |
---|---|
IOException | an exception |
public static String getResponseErrorContent(HttpURLConnection httpConn) throws IOException
//package com.java2s; // Licensed under the Apache License, Version 2.0 (the "License"); import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.HttpURLConnection; public class Main { /**//w w w.ja v a 2s .c o m * Gets the error response as a string * * @param httpConn * @return * @throws IOException */ public static String getResponseErrorContent(HttpURLConnection httpConn) throws IOException { if (httpConn.getErrorStream() == null) { return null; } else { StringBuilder sb = new StringBuilder(); BufferedReader in = new BufferedReader(new InputStreamReader(httpConn.getErrorStream())); String str; while ((str = in.readLine()) != null) { sb.append(str + "\n"); } in.close(); return sb.toString(); } } }