February 01, 2012

Network monitoring in java to get all computer names in the network


Java Network Monitoring : To get all intra networked computer list


//Java network program to list out all available computers in intranet

import java.io.*;

public class NetworkUsers
{
static String all;
public static void main(String[] args)
{try {
// Execute command

Process child = Runtime.getRuntime().exec("net view");
// Get the input stream and read from it
InputStream in = child.getInputStream();
int c;
while ((c = in.read()) != -1)
{
char e=(char)c;
System.out.println(e);
//process((char)c);
}
in.close();
} catch (IOException e) { } }

private static void process(char c) {
// TODO Auto-generated method stub
System.out.print(c);
//all =String.valueOf(c) +all;
// System.out.println(all);
}


}


 Please provide your valuable comments

No comments:

Post a Comment

Your feedback may help others !!!

Facebook comments