//***************************************************************************** // URLScan.java CPSC120B // // Demonstrate reading text from a url //***************************************************************************** import java.util.Scanner; import java.io.*; import java.net.*; public class URLScan { public static void main(String[] args) throws IOException { // initialize variables String html = "", title = ""; int titleBeginIndex, titleEndIndex; URL url = new URL("http://cs.roanoke.edu/index.html"); URLConnection urlConnection = url.openConnection(); InputStream inputStream = urlConnection.getInputStream(); Scanner scan = new Scanner(inputStream); // copy each line of the index.html file to the String html while(scan.hasNextLine()) { html += scan.nextLine(); } // find and print the title titleBeginIndex = html.indexOf("