协议未找到java.net.MalformedURLException

时间:2016-01-06 07:35:25

标签: android httpurlconnection malformedurlexception

public static Bitmap downloadImage(String link) {
    Bitmap myBitmap = null;
    try {
        URL url = new URL(link);
        System.out.println("Working");
        HttpURLConnection connection = (HttpURLConnection) url.openConnection();
        System.out.println("connection open");
        connection.setDoInput(true);
        connection.connect();
        System.out.println("connect");
        System.out.println(connection.getResponseCode());
        try {
            InputStream input = connection.getInputStream();
            myBitmap = BitmapFactory.decodeStream(input);

        } catch (Exception e) {
            e.fillInStackTrace();
            Log.v("ERROR", "Errorchence : " + e);
        }
    } catch (IOException e) {
        e.printStackTrace();
    }
    return myBitmap;
}

我正在尝试从服务器下载图片。这是我正在尝试的链接image

我从终端尝试了wget并且工作正常。 它说协议没有找到,但https在url中,因为你可以看到日志标签
我附加了 logtag

0 个答案:

没有答案