Thank you!

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown ...

Minimal Design

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown ...

Download high quality wordpress themes at top-wordpress.net

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown ...

Easy to use theme admin panel

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s, when an unknown ...

http header


import java.io.*;
import java.net.*;
import java.util.Scanner;

/** Fetches the HTML content of a web page (or HTTP header) as a String. */
public final class WebPageFetcher {

  /**
  * Demo harness.
  *
  * <ul>
  * <li>aArgs[0] : an HTTP URL
  * <li>aArgs[1] : (header | content)
  * </ul>
  */
  public static void main(String... aArgs) throws MalformedURLException {
    String url = aArgs[0];
    String option = aArgs[1];
    WebPageFetcher fetcher = new  WebPageFetcher(url);
    if ( HEADER.equalsIgnoreCase(option) ) {
      log( fetcher.getPageHeader() );
    }
    else if ( CONTENT.equalsIgnoreCase(option) ) {
      log( fetcher.getPageContent() );
    }
    else {
      log("Unknown option.");
    }
  }

  public WebPageFetcher( URL aURL ){
    if ( ! HTTP.equals(aURL.getProtocol())  ) {
      throw new IllegalArgumentException("URL is not for HTTP Protocol: " + aURL);
    }
    fURL = aURL;
  }

  public WebPageFetcher( String aUrlName ) throws MalformedURLException {
    this ( new URL(aUrlName) );
  }

  /** Fetch the HTML content of the page as simple text.   */
  public String getPageContent() {
    String result = null;
    URLConnection connection = null;
    try {
      connection =  fURL.openConnection();
      Scanner scanner = new Scanner(connection.getInputStream());
      scanner.useDelimiter(END_OF_INPUT);
      result = scanner.next();
    }
    catch ( IOException ex ) {
      log("Cannot open connection to " + fURL.toString());
    }
    return result;
  }

  /** Fetch HTML headers as simple text.  */
  public String getPageHeader(){
    StringBuilder result = new StringBuilder();

    URLConnection connection = null;
    try {
      connection = fURL.openConnection();
    }
    catch (IOException ex) {
      log("Cannot open connection to URL: " + fURL);
    }

    //not all headers come in key-value pairs - sometimes the key is
    //null or an empty String
    int headerIdx = 0;
    String headerKey = null;
    String headerValue = null;
    while ( (headerValue = connection.getHeaderField(headerIdx)) != null ) {
      headerKey = connection.getHeaderFieldKey(headerIdx);
      if ( headerKey != null && headerKey.length()>0 ) {
        result.append( headerKey );
        result.append(" : ");
      }
      result.append( headerValue );
      result.append(NEWLINE);
      headerIdx++;
    }
    return result.toString();
  }

  // PRIVATE //
  private URL fURL;
 
  private static final String HTTP = "http";
  private static final String HEADER = "header";
  private static final String CONTENT = "content";
  private static final String END_OF_INPUT = "\\Z";
  private static final String NEWLINE = System.getProperty("line.separator");

  private static void log(Object aObject){
    System.out.println(aObject);
  }
}

Ring




import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;


public class Ring {
static int n,pc,in;
static String s;
public static void main(String[] args) throws IOException {
// TODO Auto-generated method stub
BufferedReader br=new BufferedReader(new InputStreamReader (System.in));
System.out.println("Enter the Number of Clients");
n=Integer.parseInt(br.readLine());
System.out.println("Enter the Pri-Coordinator");
pc=Integer.parseInt(br.readLine());
System.out.println("Enter the Introducer");
in=Integer.parseInt(br.readLine());
s="";
for(int i=in;;)
{
System.out.print(i+"Send the Election messege to ");
s=s+i;
i=i+1;
if(i==pc)
i=i+1;
if(i>n)
i=1;
System.out.print(i+" The messege is "+s+"\n");
if(i==in)
break;
}
for(int i=n;i>=1;i--)
{
if(i!=pc && i>=i-1)
{
System.out.println("The new Co-ordinator is Selected."+i);
pc=i;
break;
}

}
for(int i=1;i<=n;i++)
{
if(i!=pc)
System.out.println("The new Co-ordinator "+pc+" is Send the ok Messege to ."+i);
}
}
}




Port scanning


import java.net.*;
import java.io.IOException;
import javax.swing.*;
public class Trial
{

public static void main(String args[])
{
  try
  {
   String str=JOptionPane.showInputDialog("Enter the host name");

   InetAddress ia=InetAddress.getByName(str);
  System.out.println("ip address is"+ia);
   for(int i=80;i<130;i++)
   {
    try
      {
       Socket s=new Socket(ia,i);
       System.out.println("port "+i+" is open");
       s.close();
       }
      catch(IOException e)
     {
     System.out.println("port "+i+"is off");
    }
   }
  }
catch(UnknownHostException e)
{ }
 }
}