March 22, 2016

How to get the list of users in network using java

How to get the list of computer users in the network




//List of users in the network

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);
}


         }

Program explanation

Inputstream implies that the program is getting input as a stream of bytes

Similar posts


How to get system details through a bat file



http://javabelazy.blogspot.in/

No comments:

Post a Comment

Your feedback may help others !!!

Facebook comments