2011-04-07 19 views

回答

1

以最簡單的形式運行循環通過IP範圍
執行命令nslookup

import java.io.*; 
public class TestExec { 
    public static void main(String[] args) { 
     try { 
      Process p = Runtime.getRuntime().exec("nslookup xx.xx.xx.xx "); 
      BufferedReader in = new BufferedReader( 
           new InputStreamReader(p.getInputStream())); 
      String line = null; 
      while ((line = in.readLine()) != null) { 
       System.out.println(line); 
      } 
     } catch (IOException e) { 
      e.printStackTrace(); 
     } 
    } 
} 

,並解析響應

+0

哇!謝謝Nirmal。這是學習和開始編碼的好例子。 – 2011-04-07 05:16:46