Java Reference
In-Depth Information
/**
* Scan a range of 256 IP addressed. Provide the prefix
* of the IP address, without the final fourth. For
* example "192.168.1".
*
* @param ip The IP address prefix(i.e. 192.168.1)
*/
public void scan(String ip)
{
if (!ip.endsWith("."))
{
ip += ".";
}
// create a list to hold sites found
List<String> list = new ArrayList<String>();
// scan through IP addresses ending in 0 - 255
for (int i = 1; i < 255; i++)
{
String address = ip + i;
String title = scanIP(address);
if (title != null)
list.add(address + ":" + title);
}
// now display the list of sites found
System.out.println();
System.out.println("Sites found:");
if (list.size() > 0)
{
for (String site : list)
{
System.out.println(site);
}
} else
{
System.out.println("No sites found");
}
}
Search WWH ::




Custom Search