0

I have an application which downloads an image from a given url like this:

Bitmap bitmap = BitmapFactory.decodeStream((InputStream) new URL(url).getContent());

And it works fine on URL like this:

http://www.test.com/images/test.jpg

But when I try to load an image from this URL:

http://www.test.com/images/מדבר.jpg

It fails and throw an java.io.FileNotFoundException.

Can anyone tell me what I need to do to load images with Hebrew characters in their URL?

UnTraDe
  • 3,747
  • 10
  • 36
  • 60

2 Answers2

1

You need to URL-escape these characters.

See this class.

http://docs.oracle.com/javase/7/docs/api/java/net/URLEncoder.html

peter.petrov
  • 38,363
  • 16
  • 94
  • 159
0

You need to url encode your URI or your files. Example:

String encodedurl = "http://www.test.com/images/" + URLEncoder.encode("מדבר.jpg","UTF-8");
StarsSky
  • 6,721
  • 6
  • 38
  • 63