如果我想读取一个别的网站页面上的一个文件,然后保存到本地,如何做呢?

来源:百度知道 编辑:UC知道 时间:2024/09/21 23:41:40
如果我想读取一个别的网站页面上的一个文件,然后保存到本地,如何做呢?

public class Test2 {
public boolean downloadHTML(String link, String file) {
boolean b = false;
URL url = null;
URLConnection conn = null;
FileWriter fr = null;
BufferedReader br = null;
try {
url = new URL(link);
conn = url.openConnection();
fr = new FileWriter(new File(file));
br = new BufferedReader(
new InputStreamReader(conn.getInputStream()));
String buf = null;
while ((buf = br.readLine()) != null) {
fr.write(buf + "\r\n");
}

} catch (MalformedURLException e) {
e.printStackTrace(System.out);
} catch (IOException e) {
e.printStackTrace(System.out);
} finally {
if (br != null) {
try {
br.close();
} catch (IOException e) {
e.printStackTrace(System.out);
}
}
if (fr != null) {
try {
fr.close();
} catch

我想装一个win2000的系统,它显示无法读取该盘,在别的机子上可以使用,这是怎么回事? 急求助!!我想从flash最终页面上点击一个button进入到网站首页 如果我想建立一个网站是否要申请营业执照呢?还需要别的手续吗? 请问我想做一个ASP的页面..读取access的数据 IFRAME读取页面上的参数 怎样删除以前上过的网站,还有怎样防止别的页面弹出 如果我知道一个网站,我想把那里面的所有东西都下载下来,不单是页面,是整个网站,有什么办法吗? 如果一个几年历史的老网站首页为动态,现在我想将首页转为静态页面网站排名收录会不会受影响? 如果我已经建立了一个网站,那我下次在别的计算机上怎么以站长身份登陆 为什么我地打开主页电脑就弹出一个别的网站页面?