从http中获得 Inputstream

/**
     * 从http中获得 Inputstream
     *
     * @param url http地址
     * @return inputstream
     * @throws java.io.IOException IOException
     */
    private static InputStream getInputStreamFromHttp(String url) throws IOException {
        URL downUrl = new URL(url);
        HttpURLConnection connection = (HttpURLConnection)downUrl.openConnection();
        connection.connect();
        if (connection.getResponseCode() == HttpURLConnection.HTTP_OK) {
            return connection.getInputStream();
        }
        return null;
    }

你可能感兴趣的:(Inputstream)