展开全部
public void test(Long clusterId,boolean monitorSendAllFlag) {
32313133353236313431303231363533e59b9ee7ad9431333337623436boolean result=false;
try {
String url ="http://www.xxx.com/xxx/xxx.action";
String json= HttpConfigUtil.getHttpResponse(url);
System.out.println(json);
} catch (Exception e) {
e.printStackTrace();
}
}
public static String getHttpResponse(String allConfigUrl) {
BufferedReader in = null;
StringBuffer result = null;
try {
URI uri = new URI(allConfigUrl);
URL url = uri.toURL();
URLConnection connection = url.openConnection();
connection.setRequestProperty("Content-Type", "application/x-www-form-urlencoded");
connection.setRequestProperty("Charset", "utf-8");
connection.connect();
result = new StringBuffer();
//读取URL的响应
in = new BufferedReader(new InputStreamReader(
connection.getInputStream()));
String line;
while ((line = in.readLine()) != null) {
result.append(line);
}
return result.toString();
} catch (Exception e) {
e.printStackTrace();
}finally {
try {
if (in != null) {
in.close();
}
} catch (Exception e2) {
e2.printStackTrace();
}
}
return null;
}
你可以根据这个写个例子试试,不会的再追问我