import java.io.*;import java.util.*;import java.net.*;public class ScannerApp { public static void main(String[] args) throws IOException { // Open up the input file. FileReader fin = new FileReader("urlFile.txt"); Scanner urlIn = new Scanner(fin); // Define the String used to hold the input URL. String urlString; // Define a sorted list to contain the URLs visited. // A sorted list is quicker to look up, and we choose the // second implementation, which is iterative. SortedListInterface urlVisitedList; urlVisitedList = new ArraySortedList2(); // Loop through the file, as long as there are more URLs. while (urlIn.hasNext()) { // Get the next input. urlString = urlIn.next(); // Before continuing, make sure the String of the URL hasn't already been saved on the visited list. if (!urlVisitedList.contains(urlString)) { // add the String of the url to the visited list urlVisitedList.add(urlString); // create a new URL object (you must name it) with the string containing the URL as a parameter to the URL URL siteURL = new URL(urlString); // Next, create an Input stream object (you must name it), using the URL object defined directly above InputStream netStream = siteURL.openStream(); // Use the input stream object defined above as input to a Scanner object Scanner fileInput = new Scanner(netStream); // Finally, simply loop through the tokens in the URL while (fileInput.hasNext()) { String urlContents = fileInput.next(); System.out.println("from the URL: " + urlContents); } // now, close the stream netStream.close(); } } }}