📄 sendrequest.java
字号:
/* * SendRequest.java *" * 创建日期: 2002年10月08日, 上午9:10" * 创建人员:Fastpoint * 修改日期: * 修改人员: */package com;import java.io.IOException;import java.io.PrintStream;import java.net.*;public class SendRequest{ public static int dd = 0; public String cookies; private String urlString; public SendRequest(String url){ cookies = null; urlString = url; } public void setCookies(String cookies){ this.cookies = cookies; } public int send(){//向被测试WEB站点发送请求连接信息,如果联接失败则抛出异常信息 long start = System.currentTimeMillis(); int len = -1; try{ URL url = new URL(urlString); URLConnection urlc = url.openConnection(); len = urlc.getContentLength(); }catch(MalformedURLException mue){ mue.printStackTrace(); }catch(UnknownHostException uhe){ System.out.println("Can't open".concat(String.valueOf(String.valueOf(uhe.getMessage())))); }catch(NoRouteToHostException nrthe){ System.out.println(nrthe.getMessage()); }catch(IOException ioe){ ioe.printStackTrace(); } long end = System.currentTimeMillis(); StressTest.out(String.valueOf(String.valueOf((new StringBuffer("访问: ")).append(urlString).append("\t所用时间:").append(end - start).append("毫秒\t网站内容长度:").append(len).append("字节")))); return 0; }}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -