Read in the current contents of the java.net homepage : Scanner « File Input Output « Java
- Java
- File Input Output
- Scanner
Read in the current contents of the java.net homepage
import java.net.URL;
import java.net.URLConnection;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws Exception {
URLConnection connection = new URL("http://java.net").openConnection();
String text = new Scanner(connection.getInputStream()).useDelimiter("\\Z").next();
}
}
Related examples in the same category