1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44
| try{
String a=text1.getText();
StringTokenizer st=new StringTokenizer(a,".");
final String a1=st.nextToken();
final String a2=st.nextToken();
final String a3=st.nextToken();
String a4=st.nextToken();
String b=text2.getText();
StringTokenizer stt=new StringTokenizer(b,".");
String b1=stt.nextToken();
String b2=stt.nextToken();
String b3=stt.nextToken();
String b4=stt.nextToken();
int x=Integer.parseInt(a4.trim());
int y=Integer.parseInt(b4.trim());
int p1;
for ( p1 = x; p1<=y ; p1++ ) {
String ip = a1+"."+a2+"."+a3+"."+p1;
InetAddress address = null;
address = InetAddress.getByName(ip);
boolean reachable;
reachable = address.isReachable(1500);
String name=address.getHostName();
if(reachable==false){
name=" ---";}
md.addRow(new Object[]{""+ip,""+name,""+reachable});
tt.setModel(md);
}
}catch(Exception e){System.out.println(e);} |
Partager