hi leudz, ich bekomm an kommentierter stelle eine NullPointerException aber leider weiß ich nicht warum
Hier ist der PingThread
Code:
import java.net.*;
import java.io.*;
public class GetNetworkIps {
public static void main(String[] args) throws Exception {
String startIp;
String ip2;
PingThread ping[] = null;
InetAddress ip = null;
BufferedReader r = new
BufferedReader(new InputStreamReader(System.in));
System.out.println("Bitte Ip eingeben: (192.168.1. << letze stelle frei lassen!!)");
startIp = r.readLine();
System.out.println();
System.out.println("Timeout: ");
String t = r.readLine();
for (int i = 1; i <= 255; i++) {
ip2 = startIp + i;
ip = InetAddress.getByName(ip2);
ping[i] = new PingThread(ip); // NullPointerException
}
}
}
Hier ist der PingThread
Code:
import java.net.InetAddress;
class PingThread extends Thread {
InetAddress ip;
PingThread(InetAddress ip) {
this.ip = ip;
}
public void run() {
try {
if (ip.isReachable( 2000 )) {
System.out.println(ip);
} else System.out.println("<><>" + ip);
} catch (Exception ex) {
System.err.println(ex.getMessage());
}
}
}