67,513
社区成员
发帖
与我相关
我的任务
分享
public static String resolve(String targetURL){
String output = "";
HttpURLConnection httpConnection = null;
try {
URL targetUrl = new URL(targetURL);
httpConnection = (HttpURLConnection) targetUrl.openConnection();
httpConnection.setDoOutput(true);
httpConnection.setRequestMethod("GET");
httpConnection.setRequestProperty("Content-Type",
"application/json");
InputStreamReader isr = new InputStreamReader(httpConnection
.getInputStream(),"utf-8");
BufferedReader responseBuffer = new BufferedReader(isr);
output = responseBuffer.readLine();
} catch (Exception e) {
e.printStackTrace();
} finally {
httpConnection.disconnect();
}
return output;
}