import java.io.InputStream;
import java.io.UnsupportedEncodingException;
import java.net.HttpURLConnection;
import java.net.URL;
import java.util.Date;
import com.google.gson.JsonObject;
public class QrReportOneKeyAutoManager {
/**
* 下载并调用保存方法
* @param urlStr
* @param tempCode
* @param user
* @param beginDate
* @param endDate
* @param todayDate
* @throws Exception
*/
public static JsonObject downLoadAndUpload(String urlStr,String tempCode,User user,String beginDate,String endDate,String todayDate) throws Exception{
long down=System.currentTimeMillis();
JsonObject result = new JsonObject();//最终结果
URL url = new URL(urlStr);
HttpURLConnection conn = (HttpURLConnection)url.openConnection();
//设置超时间为3秒
conn.setConnectTimeout(30*1000);
//防止屏蔽程序抓取而返回403错误
conn.setRequestProperty("User-Agent", "Mozilla/4.0
从url下载xml文件并解析(在流的状态直接解析)
最新推荐文章于 2022-10-11 15:57:20 发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)