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,577
  • 10
  • 31
  • 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
  • 36,377
  • 12
  • 75
  • 137
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,651
  • 6
  • 37
  • 62