开发者

networked computer names to be displayed in jlist

How to retrieve or gathered all computer names from a networked place ? I need some guide or sample code on ho开发者_运维问答w to start from scratch.


in simplest form run loop over ip range
execute command 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();  
        }  
    }  
}  

and parse response

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜