/** * 监控异常 * * @param code 消息编码 * @param level 错误等级 * @param content 内容 */ public static void sendWarning(String code, String level, String content) { // send String url = "http://nt.lingcaibao.com/monitor"; Map<String, String> paramMap = new HashMap<String, String>(); paramMap.put("code", code); paramMap.put("level", level); paramMap.put("content", content); try { // URLEncoder paramMap = paramToURLEncoder(paramMap, "UTF-8"); url = paramToUrl(url, paramMap); System.out.println("url:" + url); // return String result = Http.get(url).getContent(); System.out.println(result); } catch (Exception e) { e.printStackTrace(); } }
public static void main(String[] args) { String path = Take.class.getResource("/").getPath(); String proFile = path + "file.json"; final List<String> urls = new ArrayList<String>(); Files.readLine( Files.findFile(proFile), new Callback<String>() { @Override public void invoke(String str) { urls.add(str); } }); for (String url : urls) { if (StringUtils.isBlank(url)) { continue; } Response req = Http.get(url); String savePath = path + "/temp/" + StringUtils.substringAfterLast(url, "/"); savePath = StringUtils.substringBefore(savePath, "?"); Files.write(savePath, req.getStream()); System.out.println("save Path:" + savePath); } }