1.http形式另一个服务器数据
/**
*description:获取http接口返回值 有参数
* 返回值为 jsonarray 字符串形式
*@author: fuxb
*@date: 2021/7/28 11:00
@param path http 接口地址
@param post 参数 形式为 param1=value1¶m2=value2
*@return: com.google.gson.JsonObject
*/
public static String postDownloadJson(String path,String post){
URL url = null;
try {
url = new URL(path);
HttpURLConnection httpURLConnection = (HttpURLConnection) url.openConnection();
httpURLConnection.setRequestMethod("POST");// 提交模式
// conn.setConnectTimeout(10000);//连接超时 单位毫秒
// conn.setReadTimeout(2000);//读取超时 单位毫秒
// 发送POST请求必须设置如下两行
httpURLConnection.setDoOutput(true);
httpURLConnection.setDoInput(true);
// 获取URLConnection对象对应的输出流
PrintWriter printWriter = new PrintWriter(httpURLConnection.getOutputStream