Mega Code Archive

 
Categories / Java / File Input Output
 

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();   } }