首页 > 代码库 > 三、HTTP抓包测试
三、HTTP抓包测试
package testHTTP;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.net.URLConnection;
public class GetHTTP extends Thread{
public static void main(String[] args) {
new GetHTTP().start();
}
@Override
public void run(){
URL url;
URLConnection conn;
InputStream is;
try {
url = new URL("http://www.baidu.com");
conn = url.openConnection();
is = conn.getInputStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr);
String line;
StringBuilder builder = new StringBuilder();
while((line=br.readLine())!=null){
builder.append(line);
}
br.close();
isr.close();
is.close();
System.out.println(builder.toString());
} catch (IOException e) {
e.printStackTrace();
}
}
}
三、HTTP抓包测试