package lianxi;
import java.io.*;
import java.net.*;
import java.util.Scanner;
public class lianxi {
public static void main(String []args) {
Scanner input=null;
try {
URL url=new URL("https://home.firefoxchina.cn/".trim());
input=new Scanner(url.openStream());
while(input.hasNext())
System.out.println(input.nextLine());
}
catch (MalformedURLException e) {
// TODO 自动生成的 catch 块
System.out.println("URL没发现");
}
catch (IOException e) {
// TODO 自动生成的 catch 块
e.printStackTrace();
}
finally {
if(input!=null)
input.close();
}
}
}
在这里插入代码片
java read files from a web server
Guess you like
Origin blog.csdn.net/feiqipengcheng/article/details/104727264
Ranking