Tuesday, May 17, 2011

NetWork interface Reader


import java.io.*;
import java.net.*;
import java.util.*;
import static java.lang.System.out;
public class Main  {
  public  void  call()
  {

  }
    public static void main(String[] args) throws IOException  {
        
             Enumeration<NetworkInterface> nets = NetworkInterface.getNetworkInterfaces();
             int i=0;
        for (NetworkInterface netint : Collections.list(nets))
        {out.print("---------------------"+i+++"\n");
            displayInterfaceInformation(netint);
        }


    }
     static void displayInterfaceInformation(NetworkInterface netint) throws SocketException {
       out.printf("Display name: %s\n", netint.getDisplayName());
        out.printf("Name: %s\n", netint.getName());
        Enumeration<InetAddress> inetAddresses = netint.getInetAddresses();

        for (InetAddress inetAddress : Collections.list(inetAddresses)) {
            out.printf("InetAddress: %s\n", inetAddress);
        }

        out.printf("Up? %s\n", netint.isUp());
        out.printf("Loopback? %s\n", netint.isLoopback());
        out.printf("PointToPoint? %s\n", netint.isPointToPoint());
        out.printf("Supports multicast? %s\n", netint.supportsMulticast());
        out.printf("Virtual? %s\n", netint.isVirtual());
        out.printf("Hardware address: %s\n",
                    Arrays.toString(netint.getHardwareAddress()));
        out.printf("MTU: %s\n", netint.getMTU());

        out.printf("\n");
     }

}

JSF application with file extension .JSF



<context-param>
<param-name>javax.faces.DEFAULT_SUFFIX</param-name>
<param-value>.jsf</param-value>
</context-param>

in web.xmlin web.xml

Tuesday, May 10, 2011

Port Scanner in Java


public static void main(String[] args)  {
        URLConnection conn;
       for(int port=1;port<65535;port++)
       {
            try {
                ServerSocket serv = new ServerSocket(port);
                if(serv.isBound())
                    {
                    serv.close();
                    }
            } catch (IOException ex) {
                System.out.println(port);
            }

       }


    }