Here you can find the source of getStreamByConnection(final HttpURLConnection con)
Parameter | Description |
---|---|
con | connection which is analyzed |
Parameter | Description |
---|---|
IOException | exception which can occur in the network-task |
private static InputStream getStreamByConnection(final HttpURLConnection con) throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; import java.io.InputStream; import java.net.HttpURLConnection; public class Main { /**// w ww .j a va 2 s.c o m * Returns the inputstream or errorstream via the http-connection * * @param con connection which is analyzed * @return inputstream or errorstream * @throws IOException exception which can occur in the network-task */ private static InputStream getStreamByConnection(final HttpURLConnection con) throws IOException { InputStream stream = null; int responseCode = con.getResponseCode(); if (responseCode > 399) { stream = con.getErrorStream(); } else { stream = con.getInputStream(); } return stream; } }