URL - FileNotFoundException for image file in Android

前端 未结 6 1733
再見小時候
再見小時候 2020-12-17 04:04

I\'m trying to get a image from particular URL but it throwsFileNotFoundException. If I try to open the url from my browser, i can see the images. Please help.

6条回答
  •  轮回少年
    2020-12-17 04:50

    String fileURL = "http://sposter.smartag.my/images/KFC_Voucher.jpg";
    
    String FILENAME = "caldophilus.jpg";
    
    URL u = new URL(fileURL);
    
    HttpURLConnection c = (HttpURLConnection) u.openConnection();
    
    c.setRequestMethod("GET");
    
    //c.setDoOutput(true); =========== remove this;
    
    c.connect();
    

提交回复
热议问题