URL encoding for latin characters in Java

Posted by sammichy on Stack Overflow See other posts from Stack Overflow or by sammichy
Published on 2010-03-14T16:58:51Z Indexed on 2010/03/14 17:25 UTC
Read the original article Hit count: 431

Filed under:
|
|
|
|

I'm trying to read in an image URL. As mentioned in the java documentation, I tried converting the URL to URI by

String imageURL = "http://www.shefinds.com/files/Christian-Louboutin-Décolleté-100-pumps.jpg";
URL url = new URL(imageURL);
url = new URI(url.getProtocol(), url.getHost(), url.getFile(), null).toURL();  
URLConnection conn = url.openConnection();
InputStream is = conn.getInputStream();

I get the following error when the code is executed

http://www.shefinds.com/files/Christian-Louboutin-Décolleté-100-pumps.jpg

What am I doing wrong and what is the right way to encode this URL?

© Stack Overflow or respective owner

Related posts about java

Related posts about url