public
static
void
main(String[] args)
throws
Exception
{
HttpClient httpClient =
new
HttpClient();
httpClient.getHostConfiguration().setProxy(
"xxxx"
,
8080
);
HttpMethod method =
new
GetMethod(
"http://java.sun.com/"
);
httpClient.executeMethod(method);
InputStream in = method.getResponseBodyAsStream();
File file =
new
File(
"D:/b.html"
);
OutputStream os =
new
FileOutputStream(file);
byte
[] buff =
new
byte
[
4096
];
int
len=-
1
;
while
((len=in.read(buff))!=-
1
){
os.write(buff,
0
,len);
}
in.close();
os.close();
method.releaseConnection();
}