可以的啊。
public class Url {
public static void main(String[] args) throws IOException {
String html = getHTML("http://www.baidu.com");
write2File(html,"c:/tosave");
}
public static String getHTML(String path) throws IOException{
StringBuffer buf = new StringBuffer();
URL url = new URL(path);
BufferedReader reader = new BufferedReader(new InputStreamReader(
url.openStream()));
String temp;
while ((temp = reader.readLine()) != null) {
buf.append(temp);
}
reader.close();
return buf.toString();
}
public static void write2File(String str, String path2Save) throws IOException{
FileWriter writer = new FileWriter(new File(path2Save));
writer.write(str);
writer.flush();
writer.close();
}
}
--
FROM 101.5.97.*