展开全部
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
public class URLReader {
public static void main(String[] args) throws IOException {
URL url = new URL("http://www.baidu.com/");
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
String line = null;
while((line = br.readLine()) != null) {
System.out.println(line);
}
br.close();
}
}
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.URL;
public class URLReader {
public static void main(String[] args) throws IOException {
URL url = new URL("http://www.baidu.com/");
BufferedReader br = new BufferedReader(new InputStreamReader(url.openStream()));
String line = null;
while((line = br.readLine()) != null) {
System.out.println(line);
}
br.close();
}
}
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询