private static String getStaticPage(String surl) {
String htmlContent = ;
try {
javaioInputStream inputStream;
URL url = new URL(surl);
HttpURLConnection connection = (HttpURLConnection) urlopenConnection();
nnect();
inputStream = connectiongetInputStream();
byte bytes[] = new byte[ * ];
int index = ;
int count = inputStreamread(bytes index * );
while (count != ) {
index += count;
count = inputStreamread(bytes index );
}
htmlContent = new String(bytes UTF);
connectiondisconnect();
} catch (Exception ex) {
exprintStackTrace();
}
return htmlContenttrim();
}
String src= getStaticPage();
File file = new File(d:\l);
FileWriter resultFile = new FileWriter(file);
PrintWriter myFile = new PrintWriter(resultFile);
//写文件
myFileprintln(src);
resultFileclose();
myFileclose();