标签:tac mds 代码 edr main style close amr adl
curl java 模拟http请求
直接上代码:
1 public static void main(String args[]) throws Exception { 2 3 String url = "https://www.baidu.com"; 4 String[] cmds = {"curl",url}; 5 ProcessBuilder pb = new ProcessBuilder(cmds); 6 pb.redirectErrorStream(true); 7 Process p; 8 try { 9 p = pb.start(); 10 BufferedReader br = null; 11 String line = null; 12 br = new BufferedReader(new InputStreamReader(p.getInputStream())); 13 while ((line = br.readLine()) != null) { 14 System.out.println("\t" + line); 15 } 16 br.close(); 17 } catch (IOException e) { 18 e.printStackTrace(); 19 } 20 21 }
标签:tac mds 代码 edr main style close amr adl
原文地址:https://www.cnblogs.com/wang-yaz/p/9255269.html