Java Reference
In-Depth Information
LISTING 5.10
continued
String url;
Scanner fileScan, urlScan;
fileScan =
new
Scanner (
new
File("urls.inp"));
// Read and process each line of the file
while
(fileScan.hasNext())
{
url = fileScan.nextLine();
System.out.println ("URL: " + url);
urlScan =
new
Scanner (url);
urlScan.useDelimiter("/");
// Print each part of the url
while
(urlScan.hasNext())
System.out.println (" " + urlScan.next());
System.out.println();
}
}
}
OUTPUT
URL: thelyric.com/calendar/
thelyric.com
calendar
URL: youtube.com/watch?v=EHCRimwRGLs
youtube.com
watch?v=EHCRimwRGLs
Search WWH ::
Custom Search