Download image url contains "è"

I am trying to upload an image at the following url:

http://upload.tapcrowd.com//cache/ /_cp_100_100_stand_filière_300x212.jpg

As you can see in the browser, this shows the image, but in my application I get a FileNotFoundException.

However, if I change the URL of the image from “è” to “e”. I can successfully download it to my application. This, however, is only a temporary solution, since it should be able to upload images using the unicode icon.

How can i achieve this?

Method used to upload images:

        Bitmap bitmap = null;
        URL imageUrl = new URL(url);
        HttpURLConnection conn = (HttpURLConnection) imageUrl.openConnection();
        conn.setConnectTimeout(30000);
        conn.setReadTimeout(30000);
        conn.setInstanceFollowRedirects(true);
        InputStream is = conn.getInputStream();
        OutputStream os = new FileOutputStream(f);
        Utils.CopyStream(is, os);
        os.close();
        bitmap = decodeFile(f, maxheight, maxwidth);

which works for me:

        Bitmap bitmap = null;
        int slashIndex = url.lastIndexOf('/');
        String filename = url.substring(slashIndex + 1);
        filename = URLEncoder.encode(filename, "UTF-8");
        url = url.subSequence(0, slashIndex + 1) + filename;
        URL imageUrl = new URL(url);
        HttpURLConnection conn = (HttpURLConnection) imageUrl.openConnection();
        conn.setConnectTimeout(30000);
        conn.setReadTimeout(30000);
        conn.setInstanceFollowRedirects(true);
        InputStream is = conn.getInputStream();
        OutputStream os = new FileOutputStream(f);
        Utils.CopyStream(is, os);
        os.close();
        bitmap = decodeFile(f, maxheight, maxwidth);
+5
source share
1 answer

URL-, URLEncoder:

String baseUrl = "http://upload.tapcrowd.com//cache//";
String imageName = "_cp_100_100_stand_filière_300x212.jpg";
URL imageUrl = new URL(baseUrl+URLEncoder.encode(imageName ,"UTF-8"));

, , , URL-.

+3

All Articles