import java.net.*;
import java.io.*;public class ReadURL2 {
public static void main(String argv[]) throws Exception {
/*
if(argv.length != 1) {
System.out.println("Usage: java ReadURL2 <url>");
System.exit(0);
}
URL url = new URL(argv[0]);
*/
String szurl="http://www.shu.edu.cn";
URL url = new URL(szurl);
java.util.Properties prop = System.getProperties();
prop.put("http.proxyHost","61.240.111.196");
prop.put("http.proxyPort","80");
BufferedReader in
= new BufferedReader(new InputStreamReader(url.openStream())); String line;
StringBuffer sb = new StringBuffer();
while ((line = in.readLine()) != null) {
sb.append(line);
if(sb.length()>250)
break;
}
in.close();
System.out.println(sb.toString());
System.in.read ();
}
}
import java.io.*;public class ReadURL2 {
public static void main(String argv[]) throws Exception {
/*
if(argv.length != 1) {
System.out.println("Usage: java ReadURL2 <url>");
System.exit(0);
}
URL url = new URL(argv[0]);
*/
String szurl="http://www.shu.edu.cn";
URL url = new URL(szurl);
java.util.Properties prop = System.getProperties();
prop.put("http.proxyHost","61.240.111.196");
prop.put("http.proxyPort","80");
BufferedReader in
= new BufferedReader(new InputStreamReader(url.openStream())); String line;
StringBuffer sb = new StringBuffer();
while ((line = in.readLine()) != null) {
sb.append(line);
if(sb.length()>250)
break;
}
in.close();
System.out.println(sb.toString());
System.in.read ();
}
}
urlc.setRequestProperty ("Proxy-Authorization", "Basic " + encoding);不过我是抓的网页,不是文件,你试一下。