读书人

从http中取得 Inputstream

发布时间: 2012-06-26 10:04:13 作者: rapoo

从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;    }

读书人网 >移动开发

热点推荐