linux 环境小 sendGet方法无效,换了一种方式解决,解决代码如下
public static String httpsRequest2(String requestUrl, String requestMethod, String outputStr) {
JSONObject jsonObject = null;
StringBuffer str=new StringBuffer();
try {
String[] cmds = {"curl",requestUrl };
Process pro;
pro = Runtime.getRuntime().exec(cmds);
pro.waitFor();
InputStream in = pro.getInputStream();
BufferedReader read = new BufferedReader(new InputStreamReader(in));
String line = null;
while ((line = read.readLine()) != null) {
//System.out.println(line);
str.append(line);
}
//jsonObject = JSONObject.fromObject(str.toString());
} catch (ConnectException ce) {
ce.printStackTrace();
//log.info("连接请求异常"+ce);
} catch (Exception e) {
e.printStackTrace();
// log.info("连接请求异常"+e);
}
return str.toString();
}