<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>electrofriends.com &#187; Software Programs</title>
	<atom:link href="http://electrofriends.com/category/source-codes/software-programs/feed/" rel="self" type="application/rss+xml" />
	<link>http://electrofriends.com</link>
	<description>...bringing innovative minds together</description>
	<lastBuildDate>Fri, 30 Apr 2010 05:54:32 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Java program to display Domain name service (DNS)</title>
		<link>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-to-display-domain-name-service-dns/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-to-display-domain-name-service-dns/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 05:54:32 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Basic Programs]]></category>
		<category><![CDATA[display dns]]></category>
		<category><![CDATA[DNS]]></category>
		<category><![CDATA[Domain name servers]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1172</guid>
		<description><![CDATA[Program : Domain name service (DNS)
By : Kapil Lohia

&#160;
import java.net.*;
&#160;
class dns
&#123;
	public static void main&#40;String args&#91;&#93;&#41; throws Exception
	&#123;
		try
		&#123;
			InetAddress&#91;&#93; address=InetAddress.getAllByName&#40;&#34;java.sun.com&#34;&#41;;
			for&#40;int j=0;j&#60;address.length;j++&#41;
			System.out.println&#40;address&#91;j&#93;&#41;;
		&#125;
&#160;
		catch&#40;Exception e&#41;
		&#123;
			System.out.println&#40;&#34;Error in accessing Internet :&#34;+e&#41;;
		&#125;
	&#125;
&#125;

]]></description>
			<content:encoded><![CDATA[<p>Program : Domain name service (DNS)<br />
By : Kapil Lohia</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.net.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> dns
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">try</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">InetAddress</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> address<span style="color: #339933;">=</span><span style="color: #003399;">InetAddress</span>.<span style="color: #006633;">getAllByName</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;java.sun.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> j<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>j<span style="color: #339933;">&lt;</span>address.<span style="color: #006633;">length</span><span style="color: #339933;">;</span>j<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>address<span style="color: #009900;">&#91;</span>j<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Error in accessing Internet :&quot;</span><span style="color: #339933;">+</span>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/java/basic-programs/java-program-to-display-domain-name-service-dns/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java program to display the IP Address of a particular Host</title>
		<link>http://electrofriends.com/source-codes/software-programs/java/advanced-programs/java-program-to-display-the-ip-address-of-a-particular-host/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/java/advanced-programs/java-program-to-display-the-ip-address-of-a-particular-host/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 05:52:55 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Advanced programs]]></category>
		<category><![CDATA[display ip address]]></category>
		<category><![CDATA[host ip address]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1170</guid>
		<description><![CDATA[Program : To display the IP Address of a particular Host
By : Kapil Lohia

import java.net.*;
import java.io.*;
&#160;
public class ip_host
&#123;
	public static void main&#40;String args&#91;&#93;&#41; throws Exception
	&#123;
		System.out.println&#40;&#34;Enter the host name :&#34;&#41;;
		String n=new DataInputStream&#40;System.in&#41;.readLine&#40;&#41;;
&#160;
		InetAddress ipadd =InetAddress.getByName&#40;n&#41;;
&#160;
		System.out.println&#40;&#34;IP address :&#34;+ipadd&#41;;
	&#125;
&#125;

]]></description>
			<content:encoded><![CDATA[<p>Program : To display the IP Address of a particular Host<br />
By : Kapil Lohia</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.net.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ip_host
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Enter the host name :&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">String</span> n<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">DataInputStream</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">System</span>.<span style="color: #006633;">in</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003399;">InetAddress</span> ipadd <span style="color: #339933;">=</span><span style="color: #003399;">InetAddress</span>.<span style="color: #006633;">getByName</span><span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;IP address :&quot;</span><span style="color: #339933;">+</span>ipadd<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/java/advanced-programs/java-program-to-display-the-ip-address-of-a-particular-host/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java program to display Local machines IP Address</title>
		<link>http://electrofriends.com/source-codes/software-programs/java/advanced-programs/java-program-to-display-local-machines-ip-address/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/java/advanced-programs/java-program-to-display-local-machines-ip-address/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 05:51:24 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Advanced programs]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Local machines IP Address]]></category>
		<category><![CDATA[program]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1168</guid>
		<description><![CDATA[Program : To display Local machines IP Address
By : Kapil Lohia

import java.net.*;
import java.io.*;
&#160;
public class ip_localmachine
&#123;
	public static void main&#40;String args&#91;&#93;&#41; throws Exception
	&#123;
		InetAddress ipadd =InetAddress.getLocalHost&#40;&#41;;
		System.out.println&#40;&#34;Host and Address :&#34;+ipadd&#41;;
		System.out.println&#40;&#34;Host name :&#34;+ipadd.getHostName&#40;&#41;&#41;;
&#160;
		String n=ipadd.toString&#40;&#41;;
		System.out.println&#40;&#34;IP address :&#34;+n.substring&#40;n.indexOf&#40;&#34;/&#34;&#41;+1&#41;&#41;;
	&#125;
&#125;

]]></description>
			<content:encoded><![CDATA[<p>Program : To display Local machines IP Address<br />
By : Kapil Lohia</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.net.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> ip_localmachine
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">InetAddress</span> ipadd <span style="color: #339933;">=</span><span style="color: #003399;">InetAddress</span>.<span style="color: #006633;">getLocalHost</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Host and Address :&quot;</span><span style="color: #339933;">+</span>ipadd<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Host name :&quot;</span><span style="color: #339933;">+</span>ipadd.<span style="color: #006633;">getHostName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003399;">String</span> n<span style="color: #339933;">=</span>ipadd.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;IP address :&quot;</span><span style="color: #339933;">+</span>n.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span>n.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/java/advanced-programs/java-program-to-display-local-machines-ip-address/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>java program for Client-Server Program using TCP/IP</title>
		<link>http://electrofriends.com/source-codes/software-programs/java/advanced-programs/java-program-for-client-server-program-using-tcpip/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/java/advanced-programs/java-program-for-client-server-program-using-tcpip/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 05:47:45 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Advanced programs]]></category>
		<category><![CDATA[client server]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[tcep ip]]></category>

		<guid isPermaLink="false">http://electrofriends.com/source-codes/software-programs/java/advanced-programs/java-program-for-client-server-program-using-tcpip/</guid>
		<description><![CDATA[Program : Client-Server Program using TCP/IP
By : Kapil Lohia 
Program 1:

&#160;
import java.net.*;
import java.io.*;
&#160;
class tcpip_server
&#123;
	public static void main&#40;String args&#91;&#93;&#41; throws IOException
	&#123;
		ServerSocket n1=null;
		try
		&#123;
			n1=new ServerSocket&#40;98&#41;;
		&#125;
		catch&#40;IOException e&#41;
		&#123;
			System.err.println&#40;&#34;Port 98 could not be found&#34;&#41;;
			System.exit&#40;1&#41;;
		&#125;
		Socket c=null;
		try
		&#123;
			c=n1.accept&#40;&#41;;
			System.out.println&#40;&#34;Connection from &#34;+c&#41;;
		&#125;
		catch&#40;IOException e&#41;
		&#123;
			System.out.println&#40;&#34;Accept failed&#34;&#41;;
			System.exit&#40;1&#41;;
		&#125;
		PrintWriter out=new PrintWriter&#40;c.getOutputStream&#40;&#41;,true&#41;;
		BufferedReader in=new BufferedReader&#40;new InputStreamReader&#40;c.getInputStream&#40;&#41;&#41;&#41;;
		String n;
		BufferedReader sin=new BufferedReader&#40;new InputStreamReader&#40;System.in&#41;&#41;;
		System.out.println&#40;&#34;Ready to type now&#34;&#41;;
		while&#40;&#40;n=sin.readLine&#40;&#41;&#41;!=null&#41;
		&#123;
			out.println&#40;n&#41;;
		&#125;
		out.close&#40;&#41;;
		c.close&#40;&#41;;
		n1.close&#40;&#41;;
	&#125;
&#125;

Program 2

&#160;
import java.net.*;
import java.io.*;
&#160;
class tcpip_client
&#123;
	public static void main&#40;String args&#91;&#93;&#41; throws IOException
	&#123;
		Socket [...]]]></description>
			<content:encoded><![CDATA[<p>Program : Client-Server Program using TCP/IP<br />
By : Kapil Lohia </p>
<p><strong>Program 1:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.net.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> tcpip_server
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">ServerSocket</span> n1<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span>
		<span style="color: #009900;">&#123;</span>
			n1<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ServerSocket</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">98</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">err</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Port 98 could not be found&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #003399;">Socket</span> c<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">try</span>
		<span style="color: #009900;">&#123;</span>
			c<span style="color: #339933;">=</span>n1.<span style="color: #006633;">accept</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Connection from &quot;</span><span style="color: #339933;">+</span>c<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> e<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Accept failed&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #003399;">PrintWriter</span> out<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">PrintWriter</span><span style="color: #009900;">&#40;</span>c.<span style="color: #006633;">getOutputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,<span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">BufferedReader</span> in<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">InputStreamReader</span><span style="color: #009900;">&#40;</span>c.<span style="color: #006633;">getInputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">String</span> n<span style="color: #339933;">;</span>
		<span style="color: #003399;">BufferedReader</span> sin<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">InputStreamReader</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">System</span>.<span style="color: #006633;">in</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Ready to type now&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>n<span style="color: #339933;">=</span>sin.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			out.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		out.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		c.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		n1.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Program 2</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.net.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> tcpip_client
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">Socket</span> s<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">BufferedReader</span> b<span style="color: #339933;">=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">try</span>
		<span style="color: #009900;">&#123;</span>
			s<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Socket</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">InetAddress</span>.<span style="color: #006633;">getLocalHost</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,<span style="color: #cc66cc;">98</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			b<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">InputStreamReader</span><span style="color: #009900;">&#40;</span>s.<span style="color: #006633;">getInputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">catch</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">UnknownHostException</span> u<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">err</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;I don't know host&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">exit</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #003399;">String</span> inp<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>inp<span style="color: #339933;">=</span>b.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">!=</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>inp<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		b.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		s.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/java/advanced-programs/java-program-for-client-server-program-using-tcpip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>DatagramSocket and DatagramPacket (Client-Server Program using UDP/IP)</title>
		<link>http://electrofriends.com/source-codes/software-programs/java/advanced-programs/datagramsocket-and-datagrampacket-client-server-program-using-udpip/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/java/advanced-programs/datagramsocket-and-datagrampacket-client-server-program-using-udpip/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 05:44:20 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Advanced programs]]></category>
		<category><![CDATA[client server pragramming]]></category>
		<category><![CDATA[DatagramPacket]]></category>
		<category><![CDATA[DatagramSocket]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1162</guid>
		<description><![CDATA[Program : DatagramSocket and DatagramPacket (Client-Server Program using UDP/IP)
By : Kapil Lohia 
Program 1 :

&#160;
import java.net.*;
&#160;
class udpip_server
&#123;
	public static DatagramSocket ds;
	public static byte buffer&#91;&#93;=new byte&#91;1024&#93;;
&#160;
	public static void Myserver&#40;&#41; throws Exception
	&#123;
		int pos=0;
		while&#40;true&#41;
		&#123;
			int c=System.in.read&#40;&#41;;
			switch&#40;c&#41;
			&#123;
				case -1: System.out.println&#40;&#34;Server quits&#34;&#41;;
				return;
				case '\r':break;
				case '\n':ds.send&#40;new DatagramPacket&#40;buffer,pos,InetAddress.getLocalHost&#40;&#41;,777&#41;&#41;;
				           pos=0;
				break;
				default:
				buffer&#91;pos++&#93;=&#40;byte&#41; c;
			&#125;
		&#125;
	&#125;
&#160;
	public static void main&#40;String args&#91;&#93;&#41; throws Exception
	&#123;
		System.out.println&#40;&#34;Server [...]]]></description>
			<content:encoded><![CDATA[<p>Program : DatagramSocket and DatagramPacket (Client-Server Program using UDP/IP)<br />
By : Kapil Lohia </p>
<p><strong>Program 1 :</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.net.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> udpip_server
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">DatagramSocket</span> ds<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">byte</span> buffer<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1024</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> Myserver<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000066; font-weight: bold;">int</span> pos<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000066; font-weight: bold;">int</span> c<span style="color: #339933;">=</span><span style="color: #003399;">System</span>.<span style="color: #006633;">in</span>.<span style="color: #006633;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #000000; font-weight: bold;">switch</span><span style="color: #009900;">&#40;</span>c<span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #339933;">:</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Server quits&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">return</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">'<span style="color: #000099; font-weight: bold;">\r</span>'</span><span style="color: #339933;">:</span><span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">case</span> <span style="color: #0000ff;">'<span style="color: #000099; font-weight: bold;">\n</span>'</span><span style="color: #339933;">:</span>ds.<span style="color: #006633;">send</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">DatagramPacket</span><span style="color: #009900;">&#40;</span>buffer,pos,<span style="color: #003399;">InetAddress</span>.<span style="color: #006633;">getLocalHost</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,<span style="color: #cc66cc;">777</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				           pos<span style="color: #339933;">=</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
				<span style="color: #000000; font-weight: bold;">default</span><span style="color: #339933;">:</span>
				buffer<span style="color: #009900;">&#91;</span>pos<span style="color: #339933;">++</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#41;</span> c<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Server ready..<span style="color: #000099; font-weight: bold;">\n</span> Please type here&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		ds<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">DatagramSocket</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">888</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		Myserver<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><strong>Program 2:</strong></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;">&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.net.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> udpip_client
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">DatagramSocket</span> ds<span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">byte</span> buffer<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">1024</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> Myclient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">DatagramPacket</span> p<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">DatagramPacket</span><span style="color: #009900;">&#40;</span>buffer,buffer.<span style="color: #006633;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			ds.<span style="color: #006633;">receive</span><span style="color: #009900;">&#40;</span>p<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#40;</span>p.<span style="color: #006633;">getData</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>,<span style="color: #cc66cc;">0</span>,p.<span style="color: #006633;">getLength</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Client - Press CTRL+C to quit&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		ds<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">DatagramSocket</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">777</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		Myclient<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/java/advanced-programs/datagramsocket-and-datagrampacket-client-server-program-using-udpip/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java program for Uniform Resource Locator (URL)</title>
		<link>http://electrofriends.com/source-codes/software-programs/java/advanced-programs/java-program-for-uniform-resource-locator-url/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/java/advanced-programs/java-program-for-uniform-resource-locator-url/#comments</comments>
		<pubDate>Fri, 30 Apr 2010 05:27:24 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Advanced programs]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Uniform Resource Locator (URL)]]></category>
		<category><![CDATA[URL]]></category>

		<guid isPermaLink="false">http://electrofriends.com/source-codes/software-programs/java/advanced-programs/java-program-for-uniform-resource-locator-url/</guid>
		<description><![CDATA[Program : Uniform Resource Locator (URL)
By : Kapil Lohia

import java.net.*;
import java.io.*;
&#160;
class url
&#123;
	public static void main&#40;String args&#91;&#93;&#41; throws Exception
	&#123;
		URL n1 = new URL&#40;&#34;http://java.sun.com:80/docs/index#down&#34;&#41;;
		System.out.println&#40;&#34;Protocol:&#34;+n1.getProtocol&#40;&#41;&#41;;
		System.out.println&#40;&#34;Host :&#34;+n1.getHost&#40;&#41;&#41;;
		System.out.println&#40;&#34;File Name :&#34;+n1.getFile&#40;&#41;&#41;;
		System.out.println&#40;&#34;Port :&#34;+n1.getPort&#40;&#41;&#41;;
		System.out.println&#40;&#34;Reference :&#34;+n1.getRef&#40;&#41;&#41;;
	&#125;
&#125;

]]></description>
			<content:encoded><![CDATA[<p>Program : Uniform Resource Locator (URL)<br />
By : Kapil Lohia</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.net.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">class</span> url
<span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">Exception</span>
	<span style="color: #009900;">&#123;</span>
		<span style="color: #003399;">URL</span> n1 <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">URL</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://java.sun.com:80/docs/index#down&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Protocol:&quot;</span><span style="color: #339933;">+</span>n1.<span style="color: #006633;">getProtocol</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Host :&quot;</span><span style="color: #339933;">+</span>n1.<span style="color: #006633;">getHost</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;File Name :&quot;</span><span style="color: #339933;">+</span>n1.<span style="color: #006633;">getFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Port :&quot;</span><span style="color: #339933;">+</span>n1.<span style="color: #006633;">getPort</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Reference :&quot;</span><span style="color: #339933;">+</span>n1.<span style="color: #006633;">getRef</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/java/advanced-programs/java-program-for-uniform-resource-locator-url/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C program to implement tower of Hanoi problem</title>
		<link>http://electrofriends.com/source-codes/software-programs/c/c-advanced-programs/c-program-to-implement-tower-of-hanoi-problem/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/c/c-advanced-programs/c-program-to-implement-tower-of-hanoi-problem/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 17:28:33 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Advanced programs]]></category>
		<category><![CDATA[c program]]></category>
		<category><![CDATA[solutions]]></category>
		<category><![CDATA[tower of Hanoi problem]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1158</guid>
		<description><![CDATA[To implement tower of Hanoi problem.

#include&#60;stdio.h&#62; 	  
void hanoi_tower&#40;char,char,char,int&#41;;
void hanoi_tower&#40;char peg1,char peg2,char pege3,int n&#41;
&#123;
	if&#40;n&#60;=0&#41;
        printf&#40;&#34;\n Illegal Entry&#34;&#41;;
        if&#40;n==1&#41;
			printf &#40;&#34;\n Move disk from %c to %c&#34;, pege1,pege3&#41;;
		else
		&#123;
		   hanoi_tower&#40;peg1,peg3,peg2,n-1&#41;;
		   hanoi_tower&#40;peg1,peg2,peg3,1&#41;;
		   hanoi_tower&#40;peg2,peg1,peg3,n-1&#41;;
		&#125;
&#125;
Void main &#40;&#41;
&#123;
    [...]]]></description>
			<content:encoded><![CDATA[<p>To implement tower of Hanoi problem.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include&lt;stdio.h&gt; 	  </span>
<span style="color: #993333;">void</span> hanoi_tower<span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span><span style="color: #339933;">,</span><span style="color: #993333;">char</span><span style="color: #339933;">,</span><span style="color: #993333;">char</span><span style="color: #339933;">,</span><span style="color: #993333;">int</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #993333;">void</span> hanoi_tower<span style="color: #009900;">&#40;</span><span style="color: #993333;">char</span> peg1<span style="color: #339933;">,</span><span style="color: #993333;">char</span> peg2<span style="color: #339933;">,</span><span style="color: #993333;">char</span> pege3<span style="color: #339933;">,</span><span style="color: #993333;">int</span> n<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>n<span style="color: #339933;">&lt;=</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span> Illegal Entry&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>n<span style="color: #339933;">==</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span>
			<span style="color: #000066;">printf</span> <span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span> Move disk from %c to %c&quot;</span><span style="color: #339933;">,</span> pege1<span style="color: #339933;">,</span>pege3<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">else</span>
		<span style="color: #009900;">&#123;</span>
		   hanoi_tower<span style="color: #009900;">&#40;</span>peg1<span style="color: #339933;">,</span>peg3<span style="color: #339933;">,</span>peg2<span style="color: #339933;">,</span>n<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		   hanoi_tower<span style="color: #009900;">&#40;</span>peg1<span style="color: #339933;">,</span>peg2<span style="color: #339933;">,</span>peg3<span style="color: #339933;">,</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		   hanoi_tower<span style="color: #009900;">&#40;</span>peg2<span style="color: #339933;">,</span>peg1<span style="color: #339933;">,</span>peg3<span style="color: #339933;">,</span>n<span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span>
Void main <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">int</span> n<span style="color: #339933;">;</span>
    <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\n</span> Input the number of dise:);
    scanf(&quot;</span><span style="color: #339933;">%</span>d<span style="color: #ff0000;">&quot;, &amp;n);
    printf(&quot;</span>\n Tower of Hanoi <span style="color: #b1b100;">for</span> 5th DISC<span style="color: #ff0000;">&quot;, n);
    hanoi_tower('x','y','z',n);
}</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/c/c-advanced-programs/c-program-to-implement-tower-of-hanoi-problem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java program to implement a shape selector from a given set of shapes</title>
		<link>http://electrofriends.com/source-codes/software-programs/java/applet-programs/java-program-to-implement-a-shape-selector-from-a-given-set-of-shapes/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/java/applet-programs/java-program-to-implement-a-shape-selector-from-a-given-set-of-shapes/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 17:26:30 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Applet programs]]></category>
		<category><![CDATA[applet shapes]]></category>
		<category><![CDATA[java applet]]></category>
		<category><![CDATA[java applets]]></category>
		<category><![CDATA[shape selecotr]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1155</guid>
		<description><![CDATA[To implement a shape selector from a given set of shapes

import java.awt.*;
import java.awt.event.*;
import java.applet.*;
&#160;
public class shape extend Applet implements itemListener
&#123;
	Chekbox reet,circle,line;
	ChekboxGroup cbg;
&#160;
	String msg;
	String s1=&#34;reet&#34;;
	String s2=&#34;circle&#34;;
	string s3=&#34;line&#34;;
	publice void init&#40;&#41;
	&#123;
		cbg=new checkboxGroup&#40;&#41;;
&#160;
		rect = new checkbox&#40;&#34;reet,cbg,tru);
		circle = new Checkbox(&#34;circle&#34;,cbg.false);
		line = new Checkbox(&#34;line&#34;,cbg,false);
&#160;
		add(reet);
		add(circle);
		add(line);
&#160;
		rect.addItemListener(this);
		circle.addItemLisener(this);
		line.addItemListener(this);	
	}
	public void item StateChanged(ItemEvent ie)
	{
		repaint();
	}
	publice void paint(Graphics g)
	{
		msg=cbg.getSlectedCheckbox().getLabel();
		if(masg.compareTo(s1)==0)
		{
			g.drawRect(10,40,40,80);
		}
		else if(msg.compareTo(s2)==0)
		{
			g.drawOvel(10,40,80,80);
		}
		else
		{
			g.drawLine(0,0,100,100);
		}
	}
}

]]></description>
			<content:encoded><![CDATA[<p>To implement a shape selector from a given set of shapes</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.event.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.applet.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> shape extend <span style="color: #003399;">Applet</span> <span style="color: #000000; font-weight: bold;">implements</span> itemListener
<span style="color: #009900;">&#123;</span>
	Chekbox reet,circle,line<span style="color: #339933;">;</span>
	ChekboxGroup cbg<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #003399;">String</span> msg<span style="color: #339933;">;</span>
	<span style="color: #003399;">String</span> s1<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;reet&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #003399;">String</span> s2<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;circle&quot;</span><span style="color: #339933;">;</span>
	string s3<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;line&quot;</span><span style="color: #339933;">;</span>
	publice <span style="color: #000066; font-weight: bold;">void</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		cbg<span style="color: #339933;">=</span><span style="color: #000000; font-weight: bold;">new</span> checkboxGroup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		rect <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> checkbox<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;reet,cbg,tru);
		circle = new Checkbox(&quot;</span>circle<span style="color: #0000ff;">&quot;,cbg.false);
		line = new Checkbox(&quot;</span>line<span style="color: #0000ff;">&quot;,cbg,false);
&nbsp;
		add(reet);
		add(circle);
		add(line);
&nbsp;
		rect.addItemListener(this);
		circle.addItemLisener(this);
		line.addItemListener(this);	
	}
	public void item StateChanged(ItemEvent ie)
	{
		repaint();
	}
	publice void paint(Graphics g)
	{
		msg=cbg.getSlectedCheckbox().getLabel();
		if(masg.compareTo(s1)==0)
		{
			g.drawRect(10,40,40,80);
		}
		else if(msg.compareTo(s2)==0)
		{
			g.drawOvel(10,40,80,80);
		}
		else
		{
			g.drawLine(0,0,100,100);
		}
	}
}</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/java/applet-programs/java-program-to-implement-a-shape-selector-from-a-given-set-of-shapes/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java program to implement a Color Section from a given set of Color.</title>
		<link>http://electrofriends.com/source-codes/software-programs/java/applet-programs/java-program-to-implement-a-color-section-from-a-given-set-of-color/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/java/applet-programs/java-program-to-implement-a-color-section-from-a-given-set-of-color/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 17:02:43 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Applet programs]]></category>
		<category><![CDATA[applet color implementsion]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[java applet]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1153</guid>
		<description><![CDATA[To implement a Color Section from a given set of Color.

import java.awt*;
import java.awt.event.*;
import java.applet.*;
&#160;
public class fillcolor extends Applet implement Item Listener
&#123;
	checkbox red,yellow,black,blue.orange;
	CheckboxGroup cbg;
	String msg;
	String s1=&#34;red&#34;;
	String s2=&#34;yellow&#34;;
	String s3=&#34;black&#34;;
	String s4=&#34;orange&#34;;
	public void init&#40;&#41;
	&#123;
		cbg = new CheckboxGroup&#40;&#41;;
		red = new Chechbox&#40;&#34;red&#34;,cbg,true&#41;;
		yellow= new Checkbox&#40;&#34;yellow&#34;,cbg,false&#41;;
		black = new checkbox&#40;&#34;black&#34;,cbg,false&#41;;
		blue = new Checkbox&#40;&#34;blue&#34;,cbg,false&#41;;
		orange = new checkbox&#40;&#34;orange&#34;.cbg.false&#41;;
		add&#40;red&#41;;
		add&#40;yellow&#41;;
		add&#40;black&#41;;
		add&#40;blue&#41;;
		add&#40;orange&#41;;
		red.addItemListener&#40;this&#41;;
		yellow.addItemListener&#40;this&#41;;
		black.addItemListener&#40;this&#41;;
		blue.addItemListener&#40;this&#41;;
		orange.addItemListener&#40;this&#41;;
	&#125;
	publice void itemStartechanged&#40;ItemEvent ie&#41;
	&#123;
		repaint&#40;&#41;;
	&#125;
	publice void paint &#40;Graphics g&#41;
	&#123;
		msg = [...]]]></description>
			<content:encoded><![CDATA[<p>To implement a Color Section from a given set of Color.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> java.<span style="color: #006633;">awt</span><span style="color: #339933;">*;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.event.*</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.applet.*</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> fillcolor <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">Applet</span> implement Item Listener
<span style="color: #009900;">&#123;</span>
	checkbox red,yellow,black,blue.<span style="color: #006633;">orange</span><span style="color: #339933;">;</span>
	<span style="color: #003399;">CheckboxGroup</span> cbg<span style="color: #339933;">;</span>
	<span style="color: #003399;">String</span> msg<span style="color: #339933;">;</span>
	<span style="color: #003399;">String</span> s1<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;red&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #003399;">String</span> s2<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;yellow&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #003399;">String</span> s3<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;black&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #003399;">String</span> s4<span style="color: #339933;">=</span><span style="color: #0000ff;">&quot;orange&quot;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> init<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		cbg <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">CheckboxGroup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		red <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Chechbox<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;red&quot;</span>,cbg,<span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		yellow<span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Checkbox</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;yellow&quot;</span>,cbg,<span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		black <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> checkbox<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;black&quot;</span>,cbg,<span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		blue <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Checkbox</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;blue&quot;</span>,cbg,<span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		orange <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> checkbox<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;orange&quot;</span>.<span style="color: #006633;">cbg</span>.<span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		add<span style="color: #009900;">&#40;</span>red<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		add<span style="color: #009900;">&#40;</span>yellow<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		add<span style="color: #009900;">&#40;</span>black<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		add<span style="color: #009900;">&#40;</span>blue<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		add<span style="color: #009900;">&#40;</span>orange<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		red.<span style="color: #006633;">addItemListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		yellow.<span style="color: #006633;">addItemListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		black.<span style="color: #006633;">addItemListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		blue.<span style="color: #006633;">addItemListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		orange.<span style="color: #006633;">addItemListener</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	publice <span style="color: #000066; font-weight: bold;">void</span> itemStartechanged<span style="color: #009900;">&#40;</span><span style="color: #003399;">ItemEvent</span> ie<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		repaint<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	publice <span style="color: #000066; font-weight: bold;">void</span> paint <span style="color: #009900;">&#40;</span><span style="color: #003399;">Graphics</span> g<span style="color: #009900;">&#41;</span>
	<span style="color: #009900;">&#123;</span>
		msg <span style="color: #339933;">=</span> cbg.<span style="color: #006633;">getSelectedCheckbox</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">getLabel</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>msg.<span style="color: #006633;">compareTo</span><span style="color: #009900;">&#40;</span>s1<span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>	
		    setBackground<span style="color: #009900;">&#40;</span><span style="color: #003399;">Color</span>.<span style="color: #006633;">red</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>msg.<span style="color: #006633;">compareTo</span><span style="color: #009900;">&#40;</span>s2<span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
		    setBackground<span style="color: #009900;">&#40;</span><span style="color: #003399;">Color</span>.<span style="color: #006633;">yellow</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>msg.<span style="color: #006633;">compare</span> To<span style="color: #009900;">&#40;</span>s3<span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
		    setBackground<span style="color: #009900;">&#40;</span>color.<span style="color: #006633;">black</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">else</span> <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>msg.<span style="color: #006633;">compareTo</span><span style="color: #009900;">&#40;</span>s4<span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span>o<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
		    setBackground<span style="color: #009900;">&#40;</span><span style="color: #003399;">Color</span>.<span style="color: #006633;">blue</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">else</span>
		<span style="color: #009900;">&#123;</span>
		    set Background<span style="color: #009900;">&#40;</span><span style="color: #003399;">Color</span>.<span style="color: #006633;">orange</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

</pre>
]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/java/applet-programs/java-program-to-implement-a-color-section-from-a-given-set-of-color/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>C program for sorting a Linked List</title>
		<link>http://electrofriends.com/source-codes/software-programs/c/c-advanced-programs/c-program-for-sorting-a-linked-list/</link>
		<comments>http://electrofriends.com/source-codes/software-programs/c/c-advanced-programs/c-program-for-sorting-a-linked-list/#comments</comments>
		<pubDate>Sun, 04 Apr 2010 16:34:49 +0000</pubDate>
		<dc:creator>Ranjith</dc:creator>
				<category><![CDATA[Advanced programs]]></category>
		<category><![CDATA[c Linked List]]></category>
		<category><![CDATA[c programs]]></category>
		<category><![CDATA[linked list]]></category>
		<category><![CDATA[sorting Linked List]]></category>

		<guid isPermaLink="false">http://electrofriends.com/?p=1151</guid>
		<description><![CDATA[C program for sorting a Linked List.

#include&#60;stdio.h&#62;
#include&#60;dirent.h&#62;
#include&#60;malloc.h&#62;
#include&#60;string.h&#62;
&#160;
void main &#40;int argc,char * argv&#91;&#93;&#41;
&#123;
	DIR * directory_pointer;
	struct dirent* entry;
	struct File list 
	&#123;
		char filename&#91;64&#93;;
		struct File * new;
	&#125;
	start,*node,* previous, * new;
	if&#40;&#40;directory_pointer=opendir&#40;argv&#91;1&#93;&#41;&#41;==NULL&#41;
		printf&#40;&#34;Error opening %s\n&#34;, argv&#91;1&#93;&#41;;
	else
	&#123;
		start.next + NULL;
		while &#40;entry = readdir &#40;directory_pointer&#41;&#41;
		&#123;
			/* Find the correct location */
			previous= Start ;;
			node = start.next;
			while &#40;&#40;node&#41; &#38;&#38;&#40;strcmp&#40;entry-&#62;d_name,node-&#62;filename&#41;&#62;0&#41;&#41;
			&#123;
				node = node -&#62;next;
				previous + previous-&#62;next;
			&#125;
			new =&#40;struct File List *&#41; [...]]]></description>
			<content:encoded><![CDATA[<p>C program for sorting a Linked List.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include&lt;stdio.h&gt;</span>
<span style="color: #339933;">#include&lt;dirent.h&gt;</span>
<span style="color: #339933;">#include&lt;malloc.h&gt;</span>
<span style="color: #339933;">#include&lt;string.h&gt;</span>
&nbsp;
<span style="color: #993333;">void</span> main <span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span><span style="color: #993333;">char</span> <span style="color: #339933;">*</span> argv<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
	DIR <span style="color: #339933;">*</span> directory_pointer<span style="color: #339933;">;</span>
	<span style="color: #993333;">struct</span> dirent<span style="color: #339933;">*</span> entry<span style="color: #339933;">;</span>
	<span style="color: #993333;">struct</span> File list 
	<span style="color: #009900;">&#123;</span>
		<span style="color: #993333;">char</span> filename<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">64</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
		<span style="color: #993333;">struct</span> File <span style="color: #339933;">*</span> new<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	start<span style="color: #339933;">,*</span>node<span style="color: #339933;">,*</span> previous<span style="color: #339933;">,</span> <span style="color: #339933;">*</span> new<span style="color: #339933;">;</span>
	<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>directory_pointer<span style="color: #339933;">=</span>opendir<span style="color: #009900;">&#40;</span>argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">==</span>NULL<span style="color: #009900;">&#41;</span>
		<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Error opening %s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> argv<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #b1b100;">else</span>
	<span style="color: #009900;">&#123;</span>
		start.<span style="color: #202020;">next</span> <span style="color: #339933;">+</span> NULL<span style="color: #339933;">;</span>
		<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>entry <span style="color: #339933;">=</span> readdir <span style="color: #009900;">&#40;</span>directory_pointer<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #808080; font-style: italic;">/* Find the correct location */</span>
			previous<span style="color: #339933;">=</span> Start <span style="color: #339933;">;;</span>
			node <span style="color: #339933;">=</span> start.<span style="color: #202020;">next</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>node<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span><span style="color: #009900;">&#40;</span>strcmp<span style="color: #009900;">&#40;</span>entry<span style="color: #339933;">-&gt;</span>d_name<span style="color: #339933;">,</span>node<span style="color: #339933;">-&gt;</span>filename<span style="color: #009900;">&#41;</span><span style="color: #339933;">&gt;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				node <span style="color: #339933;">=</span> node <span style="color: #339933;">-&gt;</span>next<span style="color: #339933;">;</span>
				previous <span style="color: #339933;">+</span> previous<span style="color: #339933;">-&gt;</span>next<span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			new <span style="color: #339933;">=</span><span style="color: #009900;">&#40;</span><span style="color: #993333;">struct</span> File List <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span> malloc<span style="color: #009900;">&#40;</span>size File List<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>new <span style="color: #339933;">+=</span> <span style="color: #339933;">=</span> NULL<span style="color: #009900;">&#41;</span>
			<span style="color: #009900;">&#123;</span>
				<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Insufficient memory to store list<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				exit<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			new <span style="color: #339933;">-&gt;</span>next <span style="color: #339933;">=</span>node<span style="color: #339933;">;</span>
			previous <span style="color: #339933;">-&gt;</span>next <span style="color: #339933;">=</span>new<span style="color: #339933;">;</span>
			strcpy<span style="color: #009900;">&#40;</span>new<span style="color: #339933;">-&gt;</span>filename<span style="color: #339933;">,</span>entry<span style="color: #339933;">-&gt;</span>d_name<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		closedir<span style="color: #009900;">&#40;</span>directory_pointer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		node <span style="color: #339933;">=</span> start.<span style="color: #202020;">next</span><span style="color: #339933;">;</span>
		<span style="color: #b1b100;">while</span> <span style="color: #009900;">&#40;</span>node<span style="color: #009900;">&#41;</span>
		<span style="color: #009900;">&#123;</span>
			<span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;%s<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #339933;">,</span> node<span style="color: #339933;">-&gt;</span>filename<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			node <span style="color: #339933;">=</span> node<span style="color: #339933;">-&gt;</span>next<span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://electrofriends.com/source-codes/software-programs/c/c-advanced-programs/c-program-for-sorting-a-linked-list/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
