开发者

Java unable to connect to URL containint an umlaut

开发者 https://www.devze.com 2023-03-11 02:47 出处:网络
I seem to be unable to establish a connection to an URL with Java开发者_开发百科 that contains an umlaut.

I seem to be unable to establish a connection to an URL with Java开发者_开发百科 that contains an umlaut.

This is the url I'm trying to access: http://hakkon-aetterni.at/images/Mitglieder/Höttur.jpg

This is my Java code:

URL newLinkURL = new URL(newLink);

URLConnection uc = newLinkURL.openConnection();

String curFileContentType = uc.getContentType();

newLink url is A String containing the URL mentioned above. When trying to connect to this url i get a 500 Error in response.


You should encode part of the URL to something like this: http://hakkon-aetterni.at/images/Mitglieder/H%C3%B6ttur.jpg

URL class doesn't encodes passed parameter itself.

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

0

精彩评论

暂无评论...
验证码 换一张
取 消