錯編碼字符當我做了以下內容:解決與Java的URL給我的網址
try {
URL url = new URL(urlAsString);
//using proxy may increase latency
HttpURLConnection hConn = (HttpURLConnection) url.openConnection(Proxy.NO_PROXY);
// force no follow
hConn.setInstanceFollowRedirects(false);
// the program doesn't care what the content actually is
hConn.setRequestMethod("HEAD");
// default is 0 => infinity waiting
hConn.setConnectTimeout(timeout);
hConn.setReadTimeout(timeout);
hConn.connect();
int responseCode = hConn.getResponseCode();
hConn.getInputStream().close();
if (responseCode == HttpURLConnection.HTTP_OK)
return urlAsString;
String loc = hConn.getHeaderField("Location");
if (responseCode == HttpURLConnection.HTTP_MOVED_PERM && loc != null)
return loc.replaceAll(" ", "+");
} catch (Exception ex) {
}
return "";
該URL
:http://bit.ly/gek1qK我越來越
http://blog.tweetsmarter.com/twitter-downtime/twitter-redesignsâthen-一切 - 打破/
這是錯誤的。火狐解析
http://blog.tweetsmarter.com/twitter-downtime/twitter-redesigns%E2%80%94then-everything-breaks/
什麼是錯誤的代碼?
我是否需要爲位置應用網址編碼? – Karussell 2011-04-10 07:49:48
順便說一句:我應用編碼意外。我將url複製到Firefox的url欄中,然後從那裏粘貼到這個問題中。 Firefox應用了編碼...我在post – Karussell 2011-04-10 07:51:53
@SimonJ中修復了這個問題,所以我應該向bit.ly提交一個錯誤報告,或者這可以修復得不同嗎? – Karussell 2011-04-10 07:54:12