哪个库或内置功能可以让您使用 bitly、fb.me、google 的缩短器等缩短的 URL 并在最快的时间内获得其最终链接?
谢谢
最佳答案
programming time mostly, I'm using httpclient from apache right now wondering if their are any alternatives built in
String location = "http://tinyurl.com/so-hints";
HttpURLConnection connection = (HttpURLConnection) new URL(location).openConnection();
connection.setInstanceFollowRedirects(false);
while (connection.getResponseCode() / 100 == 3) {
location = connection.getHeaderField("location");
connection = (HttpURLConnection) new URL(location).openConnection();
}
System.out.println(location); // http://msmvps.com/blogs/jon_skeet/archive/2010/08/29/writing-the-perfect-question.aspx
关于java - 在 Java 中解析到其目标 URL 的缩短链接的最快方法是什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4505358/