help me to solve this error: -
import java.io.IOException;
import java.net.InetAddress;
import java.net.NetworkInterface;
import java.net.URLConnection;
import java.net.UnknownHostException;
import java.net.*;
public class IsReachable
{
public static void main(final String[] args) throws IOException
{
InetAddress host;
try
{
for (int i = 1; i < 255; i++)
{
host = InetAddress.getByName("192.168.6." + i);
NetworkInterface network = NetworkInterface.getByInetAddress(host);
byte[] mac = new byte[100];
mac=network.getHardwareAddress();
StringBuilder sb = new StringBuilder();
for (int j = 0; j < mac.length; j++)
{
sb.append(String.format("%02X%s", mac[j], (j < mac.length - 1) ? "-" : ""));
}
if (host.isReachable(10000))
{
System.out.println("Connected " + host + " " + sb.toString());
}
else
{
System.out.println("Failed " + host);
}
}
}
catch (UnknownHostException e) {
e.printStackTrace();
}
catch (SocketException e) {
e.printStackTrace();
}
}
}
____________Output______________
C:\Program Files\Java\jdk1.6.0_05\bin>javac IsReachable.java
C:\Program Files\Java\jdk1.6.0_05\bin>java IsReachable
Exception in thread "main" java.lang.NullPointerException
at IsReachable.main(IsReachable.java:32)
thank u