當我嘗試創建一個可調用的類時,我似乎遇到了上述錯誤。我尋找了原因,但似乎無法找到任何東西。 NetBeans爲我提供了幾個選項來使事情變得抽象,但我對此很陌生,我寧願找出發生的原因。任何人都可以闡明這一點嗎?可調用的類給出錯誤:doPing不是抽象的,也不重寫抽象方法調用()?
public class doPing implements Callable<String>{
public String call(String IPtoPing) throws Exception{
String pingOutput = null;
//gets IP address and places into new IP object
InetAddress IPAddress = InetAddress.getByName(IPtoPing);
//finds if IP is reachable or not. a timeout timer of 3000 milliseconds is set.
//Results can vary depending on permissions so cmd method of doing this has also been added as backup
boolean reachable = IPAddress.isReachable(1400);
if (reachable){
pingOutput = IPtoPing + " is reachable.\n";
}else{
//runs ping command once on the IP address in CMD
Process ping = Runtime.getRuntime().exec("ping " + IPtoPing + " -n 1 -w 300");
//reads input from command line
BufferedReader in = new BufferedReader(new InputStreamReader(ping.getInputStream()));
String line;
int lineCount = 0;
while ((line = in.readLine()) != null) {
//increase line count to find part of command prompt output that we want
lineCount++;
//when line count is 3 print result
if (lineCount == 3){
pingOutput = "Ping to " + IPtoPing + ": " + line + "\n";
}
}
}
return pingOutput;
}
}
感謝您的回覆:) – DMo 2012-04-03 11:57:19