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
精彩评论