<?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>TechieDrill &#187; Java</title>
	<atom:link href="http://techiedrill.com/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://techiedrill.com</link>
	<description>Your World Of Technical Tutorials</description>
	<lastBuildDate>Tue, 05 Jan 2010 16:50:11 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.5</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Java Programming Tutorial &#8211; 1 &#8211; Installing the JDK</title>
		<link>http://techiedrill.com/2009/12/java-programming-tutorial-1-installing-the-jdk/</link>
		<comments>http://techiedrill.com/2009/12/java-programming-tutorial-1-installing-the-jdk/#comments</comments>
		<pubDate>Tue, 15 Dec 2009 17:08:22 +0000</pubDate>
		<dc:creator>Venkatesh Viswanathan</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Installing]]></category>
		<category><![CDATA[JDK]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Tutorial]]></category>

		<guid isPermaLink="false">http://techiedrill.com/?p=484</guid>
		<description><![CDATA[
To download this you tube video, Click Here
Tutorial on Installing the JDK.
]]></description>
			<content:encoded><![CDATA[<p><object width="445" height="364"><param name="movie" value="http://www.youtube.com/v/Hl-zzrqQoSE&#038;hl=en_US&#038;fs=1&#038;color1=0x234900&#038;color2=0x4e9e00&#038;border=1"></param><param name="allowFullScreen" value="true"></param><param name="allowscriptaccess" value="always"></param><embed src="http://www.youtube.com/v/Hl-zzrqQoSE&#038;hl=en_US&#038;fs=1&#038;color1=0x234900&#038;color2=0x4e9e00&#038;border=1" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" width="445" height="364"></embed></object></p>
<p>To download this you tube video, <a href="http://www.keephd.com/watch?v=Hl-zzrqQoSE">Click Here</a></p>
<p><strong>Tutorial on Installing the JDK.</strong></p>
]]></content:encoded>
			<wfw:commentRss>http://techiedrill.com/2009/12/java-programming-tutorial-1-installing-the-jdk/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Inner class within a for loop</title>
		<link>http://techiedrill.com/2009/12/inner-class-within-a-for-loop/</link>
		<comments>http://techiedrill.com/2009/12/inner-class-within-a-for-loop/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 19:03:11 +0000</pubDate>
		<dc:creator>karnamrajesh</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[for]]></category>
		<category><![CDATA[loop]]></category>

		<guid isPermaLink="false">http://techiedrill.com/?p=482</guid>
		<description><![CDATA[class Outer
{
 //int i;
 public void Display()
 {
 System.out.println(&#8221;hi&#8221;);
 
 
 for(int i=1;i&#60;=10;i++)
 { 
 
 class Inner
 {
 
 public void MethodInner()
 {
 System.out.println(&#8221;Hello&#8221;);
 }
 }
 Inner a=new Inner();
 a.MethodInner();
 }
 } 
}
public class ForRegInnerClass
{
 public static void main(String args[])
 {
 Outer ou=new Outer();
 ou.Display();
 }
}
A tricky for loop with inner class
class Outer
{
 //int [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">class Outer</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>//int i;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>public void Display()</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>System.out.println(&#8221;hi&#8221;);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>for(int i=1;i&lt;=10;i++)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{<span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>class Inner</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>public void MethodInner()</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>System.out.println(&#8221;Hello&#8221;);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>Inner a=new Inner();</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>a.MethodInner();</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}<span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">public class ForRegInnerClass</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>public static void main(String args[])</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>Outer ou=new Outer();</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>ou.Display();</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<p>A tricky for loop with inner class</p>
<p>class Outer</p>
<p>{</p>
<p><span style="white-space: pre;"> </span>//int i;</p>
<p><span style="white-space: pre;"> </span>public void Display()</p>
<p><span style="white-space: pre;"> </span>{</p>
<p><span style="white-space: pre;"> </span>System.out.println(&#8221;hi&#8221;);</p>
<p><span style="white-space: pre;"> </span></p>
<p><span style="white-space: pre;"> </span></p>
<p><span style="white-space: pre;"> </span>for(int i=1;i&lt;=10;i++)</p>
<p><span style="white-space: pre;"> </span>{<span style="white-space: pre;"> </span></p>
<p><span style="white-space: pre;"> </span></p>
<p><span style="white-space: pre;"> </span>class Inner</p>
<p><span style="white-space: pre;"> </span>{</p>
<p><span style="white-space: pre;"> </span></p>
<p><span style="white-space: pre;"> </span>public void MethodInner()</p>
<p><span style="white-space: pre;"> </span>{</p>
<p><span style="white-space: pre;"> </span>System.out.println(&#8221;Hello&#8221;);</p>
<p><span style="white-space: pre;"> </span>}</p>
<p><span style="white-space: pre;"> </span>}</p>
<p><span style="white-space: pre;"> </span>Inner a=new Inner();</p>
<p><span style="white-space: pre;"> </span>a.MethodInner();</p>
<p><span style="white-space: pre;"> </span>}</p>
<p><span style="white-space: pre;"> </span>}<span style="white-space: pre;"> </span></p>
<p>}</p>
<p>public class ForRegInnerClass</p>
<p>{</p>
<p><span style="white-space: pre;"> </span>public static void main(String args[])</p>
<p><span style="white-space: pre;"> </span>{</p>
<p><span style="white-space: pre;"> </span>Outer ou=new Outer();</p>
<p><span style="white-space: pre;"> </span>ou.Display();</p>
<p><span style="white-space: pre;"> </span>}</p>
<p>}</p>
]]></content:encoded>
			<wfw:commentRss>http://techiedrill.com/2009/12/inner-class-within-a-for-loop/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Inner class</title>
		<link>http://techiedrill.com/2009/12/java-inner-class/</link>
		<comments>http://techiedrill.com/2009/12/java-inner-class/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 19:00:19 +0000</pubDate>
		<dc:creator>karnamrajesh</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[class]]></category>
		<category><![CDATA[inner]]></category>

		<guid isPermaLink="false">http://techiedrill.com/?p=479</guid>
		<description><![CDATA[class Outer
{
 String s=&#8221;Welcome&#8221;;
 public void MethodInner()
 {
 Inner in=new Inner();
 in.InnerMethod();
 }
 class Inner
 {
 public void InnerMethod()
 {
 System.out.println(&#8221;Hello!&#8221;+s);
 }
 }
}
class RegInnerClass
{
 public static void main(String args[])
 {
 Outer ou=new Outer();
 ou.MethodInner();
 }
}
Classes that are defined inside another class are called inner class or nested class. Inner classes benefits in access control and naming control.
Try [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">class Outer</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>String s=&#8221;Welcome&#8221;;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>public void MethodInner()</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>Inner in=new Inner();</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>in.InnerMethod();</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>class Inner</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>public void InnerMethod()</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>System.out.println(&#8221;Hello!&#8221;+s);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">class RegInnerClass</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>public static void main(String args[])</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>Outer ou=new Outer();</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>ou.MethodInner();</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<p>Classes that are defined inside another class are called inner class or nested class. Inner classes benefits in access control and naming control.</p>
<p>Try out the below code</p>
<p>class Outer</p>
<p>{</p>
<p><span style="white-space: pre;"> </span>String s=&#8221;Welcome&#8221;;</p>
<p><span style="white-space: pre;"> </span>public void MethodInner()</p>
<p><span style="white-space: pre;"> </span>{</p>
<p><span style="white-space: pre;"> </span>Inner in=new Inner();</p>
<p><span style="white-space: pre;"> </span>in.InnerMethod();</p>
<p><span style="white-space: pre;"> </span>}</p>
<p><span style="white-space: pre;"> </span>class Inner</p>
<p><span style="white-space: pre;"> </span>{</p>
<p><span style="white-space: pre;"> </span>public void InnerMethod()</p>
<p><span style="white-space: pre;"> </span>{</p>
<p><span style="white-space: pre;"> </span>System.out.println(&#8221;Hello!&#8221;+s);</p>
<p><span style="white-space: pre;"> </span>}</p>
<p><span style="white-space: pre;"> </span>}</p>
<p>}</p>
<p>class RegInnerClass</p>
<p>{</p>
<p><span style="white-space: pre;"> </span>public static void main(String args[])</p>
<p><span style="white-space: pre;"> </span>{</p>
<p><span style="white-space: pre;"> </span>Outer ou=new Outer();</p>
<p><span style="white-space: pre;"> </span>ou.MethodInner();</p>
<p><span style="white-space: pre;"> </span>}</p>
<p>}</p>
]]></content:encoded>
			<wfw:commentRss>http://techiedrill.com/2009/12/java-inner-class/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Servlet Sample Program</title>
		<link>http://techiedrill.com/2009/12/java-servlet-sample-program/</link>
		<comments>http://techiedrill.com/2009/12/java-servlet-sample-program/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 18:42:20 +0000</pubDate>
		<dc:creator>karnamrajesh</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[program]]></category>
		<category><![CDATA[sample]]></category>
		<category><![CDATA[servlet]]></category>
		<category><![CDATA[servlets]]></category>

		<guid isPermaLink="false">http://techiedrill.com/?p=475</guid>
		<description><![CDATA[import javax.servlet.*;
import java.io.*;
public class HelloServlet extends HttpServlet
{
 public void doGet(HttpServletRequest request,
 HttpServletResponse response)
 throws ServletException, IOException
 {
 response.setContentType(&#8221;text/html&#8221;);
 PrintWriter out = response.getWriter();
 out.println(&#8221;&#60;html&#62;&#60;head&#62;&#60;title&#62;Hello!&#60;/title&#62;&#60;/head&#62;&#8221;);
 out.println(&#8221;&#60;body bgcolor=\&#8221;white\&#8221;&#62;&#60;h1&#62;Hello Servlet World&#60;/h1&#62;&#8221;);
 out.println(&#8221;&#60;/body&#62;&#60;/html&#62;&#8221;);
 out.close();
 }
}
Servlets are the server side programming language.
Servlets are loaded by the container which instantiates the init() followed by the service() method. Destory() method is called to take [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">import javax.servlet.*;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">import java.io.*;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">public class HelloServlet extends HttpServlet</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>public void doGet(HttpServletRequest request,</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>HttpServletResponse response)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>throws ServletException, IOException</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>response.setContentType(&#8221;text/html&#8221;);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>PrintWriter out = response.getWriter();</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>out.println(&#8221;&lt;html&gt;&lt;head&gt;&lt;title&gt;Hello!&lt;/title&gt;&lt;/head&gt;&#8221;);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>out.println(&#8221;&lt;body bgcolor=\&#8221;white\&#8221;&gt;&lt;h1&gt;Hello Servlet World&lt;/h1&gt;&#8221;);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>out.println(&#8221;&lt;/body&gt;&lt;/html&gt;&#8221;);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>out.close();</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<p>Servlets are the server side programming language.</p>
<p>Servlets are loaded by the container which instantiates the init() followed by the service() method. Destory() method is called to take the servlets out of service. init() and destroy() methods are called automatically and are called only once throughout the life cycle</p>
<p>Try out the sample simple servlet program</p>
<p>import javax.servlet.*;</p>
<p>import java.io.*;</p>
<p>public class HelloServlet extends HttpServlet</p>
<p>{</p>
<p><span style="white-space: pre;"> </span>public void doGet(HttpServletRequest request,</p>
<p><span style="white-space: pre;"> </span>HttpServletResponse response)</p>
<p><span style="white-space: pre;"> </span>throws ServletException, IOException</p>
<p><span style="white-space: pre;"> </span>{</p>
<p><span style="white-space: pre;"> </span>response.setContentType(&#8221;text/html&#8221;);</p>
<p><span style="white-space: pre;"> </span>PrintWriter out = response.getWriter();</p>
<p><span style="white-space: pre;"> </span>out.println(&#8221;&lt;html&gt;&lt;head&gt;&lt;title&gt;Hello!&lt;/title&gt;&lt;/head&gt;&#8221;);</p>
<p><span style="white-space: pre;"> </span>out.println(&#8221;&lt;body bgcolor=\&#8221;white\&#8221;&gt;&lt;h1&gt;Hello Servlet World&lt;/h1&gt;&#8221;);</p>
<p><span style="white-space: pre;"> </span>out.println(&#8221;&lt;/body&gt;&lt;/html&gt;&#8221;);</p>
<p><span style="white-space: pre;"> </span>out.close();</p>
<p><span style="white-space: pre;"> </span>}</p>
<p>}</p>
]]></content:encoded>
			<wfw:commentRss>http://techiedrill.com/2009/12/java-servlet-sample-program/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Thread Synchronization</title>
		<link>http://techiedrill.com/2009/12/java-thread-synchronization/</link>
		<comments>http://techiedrill.com/2009/12/java-thread-synchronization/#comments</comments>
		<pubDate>Sat, 05 Dec 2009 18:34:25 +0000</pubDate>
		<dc:creator>karnamrajesh</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[sync]]></category>
		<category><![CDATA[synchronization]]></category>
		<category><![CDATA[thread]]></category>

		<guid isPermaLink="false">http://techiedrill.com/?p=473</guid>
		<description><![CDATA[Consider a multi-threaded environment in which a thread access write and read of a same resource thread, java gives wrong output.
Consider a scenario in which java access a resource in which one thread does the read operation and write thread does the write operation then file will be corrupted, locking the access is necessary to [...]]]></description>
			<content:encoded><![CDATA[<p>Consider a multi-threaded environment in which a thread access write and read of a same resource thread, java gives wrong output.</p>
<p>Consider a scenario in which java access a resource in which one thread does the read operation and write thread does the write operation then file will be corrupted, locking the access is necessary to overcome this.</p>
<p>Try out this example to understand better</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">import java.lang.*;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">class MyThread extends Thread</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>static String message[] = {&#8221;I&#8221;, &#8220;LOVE&#8221;, &#8220;JAVA&#8221;, &#8220;VERY&#8221;, &#8220;MUCH&#8221;};</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>public MyThread(String id)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>super(id);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>public void run()</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>Sync.displayList(getName(),message);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>void waiting()</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>try</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>sleep(1000);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>catch(InterruptedException e)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>System.out.println(&#8221;Interrupted&#8221;);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">class Sync</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>public static void displayList(String name, String list[])</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>for(int i = 0; i &lt; list.length ; i++)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>MyThread thread = (MyThread)Thread.currentThread();</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>thread.waiting();0</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>System.out.println(name + list[i]);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">class ThreadSync</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>public static void main(String args[])</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>MyThread thread1 = new MyThread(&#8221;Thread 1:&#8221;);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>MyThread thread2 = new MyThread(&#8221;Thread 2:&#8221;);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>thread1.start(); //starts first thread</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>thread2.start(); //starts second thread</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 46px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<p>import java.lang.*;</p>
<p>class MyThread extends Thread</p>
<p>{</p>
<p><span style="white-space: pre;"> </span>static String message[] = {&#8221;I&#8221;, &#8220;LOVE&#8221;, &#8220;JAVA&#8221;, &#8220;VERY&#8221;, &#8220;MUCH&#8221;};</p>
<p><span style="white-space: pre;"> </span>public MyThread(String id)</p>
<p><span style="white-space: pre;"> </span>{</p>
<p><span style="white-space: pre;"> </span>super(id);</p>
<p><span style="white-space: pre;"> </span>}</p>
<p><span style="white-space: pre;"> </span>public void run()</p>
<p><span style="white-space: pre;"> </span>{</p>
<p><span style="white-space: pre;"> </span>Sync.displayList(getName(),message);</p>
<p><span style="white-space: pre;"> </span>}</p>
<p><span style="white-space: pre;"> </span>void waiting()</p>
<p><span style="white-space: pre;"> </span>{</p>
<p><span style="white-space: pre;"> </span>try</p>
<p><span style="white-space: pre;"> </span>{</p>
<p><span style="white-space: pre;"> </span>sleep(1000);</p>
<p><span style="white-space: pre;"> </span>}</p>
<p><span style="white-space: pre;"> </span>catch(InterruptedException e)</p>
<p><span style="white-space: pre;"> </span>{</p>
<p><span style="white-space: pre;"> </span>System.out.println(&#8221;Interrupted&#8221;);</p>
<p><span style="white-space: pre;"> </span>}</p>
<p><span style="white-space: pre;"> </span>}</p>
<p>}</p>
<p>class Sync</p>
<p>{</p>
<p><span style="white-space: pre;"> </span>public static void displayList(String name, String list[])</p>
<p><span style="white-space: pre;"> </span>{</p>
<p><span style="white-space: pre;"> </span>for(int i = 0; i &lt; list.length ; i++)</p>
<p><span style="white-space: pre;"> </span>{</p>
<p><span style="white-space: pre;"> </span>MyThread thread = (MyThread)Thread.currentThread();</p>
<p><span style="white-space: pre;"> </span>thread.waiting();0</p>
<p><span style="white-space: pre;"> </span>System.out.println(name + list[i]);</p>
<p><span style="white-space: pre;"> </span>}</p>
<p><span style="white-space: pre;"> </span>}</p>
<p>}</p>
<p>class ThreadSync</p>
<p>{</p>
<p><span style="white-space: pre;"> </span>public static void main(String args[])</p>
<p><span style="white-space: pre;"> </span>{</p>
<p><span style="white-space: pre;"> </span>MyThread thread1 = new MyThread(&#8221;Thread 1:&#8221;);</p>
<p><span style="white-space: pre;"> </span>MyThread thread2 = new MyThread(&#8221;Thread 2:&#8221;);</p>
<p><span style="white-space: pre;"> </span>thread1.start(); //starts first thread</p>
<p><span style="white-space: pre;"> </span>thread2.start(); //starts second thread</p>
<p><span style="white-space: pre;"> </span>}</p>
<p>}</p>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://techiedrill.com/2009/12/java-thread-synchronization/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java SuppressWarnings</title>
		<link>http://techiedrill.com/2009/11/java-suppresswarnings/</link>
		<comments>http://techiedrill.com/2009/11/java-suppresswarnings/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 16:48:24 +0000</pubDate>
		<dc:creator>karnamrajesh</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[supress]]></category>
		<category><![CDATA[warning]]></category>

		<guid isPermaLink="false">http://techiedrill.com/?p=460</guid>
		<description><![CDATA[Java Annotation offers a feature to suppress warnings that occurs during compile time. Basically there are seven level of suppressions that can be added to the java class
They are as follows:

all
finally
serial
path
fallthrough
unchecked
deprecation

Find below the deprecation suppress warning example
import java.util.Date;
public class SuppressWarningsExample
{
 //@SuppressWarnings(value=(&#8221;deprecation&#8221;))
 public static void main(String args[])
 {
 Date date = new Date(2008,9,30);
 System.out.println(&#8221;date = &#8221; [...]]]></description>
			<content:encoded><![CDATA[<p>Java Annotation offers a feature to suppress warnings that occurs during compile time. Basically there are seven level of suppressions that can be added to the java class</p>
<p>They are as follows:</p>
<ul>
<li><span style="font-family: 'Courier New', Courier, monospace; white-space: pre;">all</span></li>
<li><span style="font-family: 'Courier New', Courier, monospace;"><span style="white-space: pre;">finally</span></span></li>
<li><span style="font-family: 'Courier New', Courier, monospace;"><span style="white-space: pre;">serial</span></span></li>
<li><span style="font-family: 'Courier New', Courier, monospace; white-space: pre;">path</span></li>
<li><span style="font-family: 'Courier New', Courier, monospace; white-space: pre;">fallthrough</span></li>
<li><span style="font-family: 'Courier New', Courier, monospace; white-space: pre;">unchecked</span></li>
<li><span style="font-family: 'Courier New', Courier, monospace;"><span style="white-space: pre;">deprecation</span></span></li>
</ul>
<p>Find below the <em><strong>deprecation</strong></em> suppress warning example</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 106px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">import java.util.Date;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 106px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">public class SuppressWarningsExample</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 106px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 106px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>//@SuppressWarnings(value=(&#8221;deprecation&#8221;))</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 106px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>public static void main(String args[])</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 106px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 106px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>Date date = new Date(2008,9,30);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 106px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>System.out.println(&#8221;date = &#8221; +date);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 106px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 106px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<p><em>import java.util.Date;</em></p>
<p><em><br />
</em></p>
<p><em>public class SuppressWarningsExample</em></p>
<p><em>{</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>//@SuppressWarnings(value=(&#8221;deprecation&#8221;))</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>public static void main(String args[])</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>{</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>Date date = new Date(2008,9,30);</em></p>
<p><em><br />
</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>System.out.println(&#8221;date = &#8221; +date);</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>}</em></p>
<p><em>}</em></p>
<div></div>
]]></content:encoded>
			<wfw:commentRss>http://techiedrill.com/2009/11/java-suppresswarnings/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Static ArrayCopy</title>
		<link>http://techiedrill.com/2009/11/java-static-arraycopy/</link>
		<comments>http://techiedrill.com/2009/11/java-static-arraycopy/#comments</comments>
		<pubDate>Mon, 23 Nov 2009 16:40:43 +0000</pubDate>
		<dc:creator>karnamrajesh</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[array]]></category>
		<category><![CDATA[copy]]></category>
		<category><![CDATA[static]]></category>

		<guid isPermaLink="false">http://techiedrill.com/?p=456</guid>
		<description><![CDATA[Java offers a static ArrayCopy method from System class:
java.lang.System.arraycopy() method offers a convenient method to copy array elements from one array to another.
System.arraycopy(Object source_array, int source_position, 
Object destination_array, int destination_position, number_of_elements)
System.arraycopy() takes five parameters.
First parameter specifies the source_array from where the elements need to be copied.
Second parameter is the position(index) value of the source array [...]]]></description>
			<content:encoded><![CDATA[<p>Java offers a static <strong>ArrayCopy </strong>method from System class:</p>
<p><strong>java.lang.System.arraycopy()</strong> method offers a convenient method to copy array elements from one array to another.</p>
<p><em><strong>System.arraycopy(Object source_array, int source_position, </strong></em></p>
<p><em><strong>Object destination_array, int destination_position, number_of_elements)</strong></em></p>
<p>System.arraycopy() takes five parameters.</p>
<p>First parameter specifies the source_array from where the elements need to be copied.</p>
<p>Second parameter is the position(index) value of the source array from what index array is to be copied.</p>
<p>Third parameter specifies the destination array to which array the values need to be copied. Fourth parameter specifies the destination array starting index.</p>
<p>Fifth parameter specifies the numberOfElements need to be copied from source array to destination array.</p>
<p>Check out your understanding with below example.</p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">import java.io.*;</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">class Student</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>int b[] = new int[5];</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>Student(int[] a)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">System.arraycopy(a,0,b,0,5);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>void Display()</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>for(int i=0;i&lt;5;i++)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>System.out.println(b[i]);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">class StudentClass</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>public static void main(String [] args) throws IOException</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>DataInputStream dis = new DataInputStream(System.in);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>int a[] = new int[5];</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>System.out.print(&#8221;Enter marks : &#8220;);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>for(int i=0;i&lt;5;i++)</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>a[i]=Integer.parseInt(dis.readLine());</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>Student st = new Student(a);</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>st.Display();</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 331px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<p><em>import java.io.*;</em></p>
<p><em>class Student</em></p>
<p><em>{</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>int b[] = new int[5];</em></p>
<p><span style="white-space: pre;"><em> </em></span></p>
<p><span style="white-space: pre;"><em> </em></span><em>Student(int[] a)</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>{</em></p>
<p><span style="white-space: pre;"><em> </em></span></p>
<p><em>System.arraycopy(a,0,b,0,5);</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>}</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>void Display()</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>{</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>for(int i=0;i&lt;5;i++)</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>{</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>System.out.println(b[i]);</em></p>
<p><span style="white-space: pre;"><em> </em></span></p>
<p><span style="white-space: pre;"><em> </em></span><em>}</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>}</em></p>
<p><em>}</em></p>
<p><em>class StudentClass</em></p>
<p><em>{</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>public static void main(String [] args) throws IOException</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>{</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>DataInputStream dis = new DataInputStream(System.in);</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>int a[] = new int[5];</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>System.out.print(&#8221;Enter marks : &#8220;);</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>for(int i=0;i&lt;5;i++)</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>{</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>a[i]=Integer.parseInt(dis.readLine());</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>}</em></p>
<p><span style="white-space: pre;"><em> </em></span></p>
<p><span style="white-space: pre;"><em> </em></span><em>Student st = new Student(a);</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>st.Display();</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>}</em></p>
<p><em>}</em></p>
]]></content:encoded>
			<wfw:commentRss>http://techiedrill.com/2009/11/java-static-arraycopy/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Annotations</title>
		<link>http://techiedrill.com/2009/11/java-annotations/</link>
		<comments>http://techiedrill.com/2009/11/java-annotations/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 08:09:27 +0000</pubDate>
		<dc:creator>karnamrajesh</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[annotation]]></category>
		<category><![CDATA[annotations]]></category>

		<guid isPermaLink="false">http://techiedrill.com/?p=452</guid>
		<description><![CDATA[public class OverrideAnnotation
{
 public static void main(String s[])
 {
 OverrideExample e = new OverrideExample();
 System.out.println(e.toString());
 }
}
Annotations are kind of meta data which can be used in java classes. Typically methods, variables, classes and packages can be annotated.
Annotations basically provides information to the java compilers. Annotations can able to used to generate XMLs.
Try out the below [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">public class OverrideAnnotation</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>public static void main(String s[])</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>{</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>OverrideExample e = new OverrideExample();</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>System.out.println(e.toString());</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"> </span>}</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">}</div>
<p>Annotations are kind of meta data which can be used in java classes. Typically methods, variables, classes and packages can be annotated.</p>
<p>Annotations basically provides information to the java compilers. Annotations can able to used to generate XMLs.</p>
<p>Try out the below sample code</p>
<p>public class OverrideAnnotation</p>
<p>{</p>
<p><span style="white-space: pre;"> </span>public static void main(String s[])</p>
<p><span style="white-space: pre;"> </span>{</p>
<p><span style="white-space: pre;"> </span>OverrideExample e = new OverrideExample();</p>
<p><span style="white-space: pre;"> </span>System.out.println(e.toString());</p>
<p><span style="white-space: pre;"> </span>}</p>
<p>}</p>
<div>&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;&#8212;</div>
<div>
<div>class OverrideExample</div>
<div>{</div>
<div><span style="white-space: pre;"> </span>public String field;</div>
<div><span style="white-space: pre;"> </span>private String attribute;</div>
<div><span style="white-space: pre;"> </span>@Override</div>
<div><span style="white-space: pre;"> </span>public int hashCode()</div>
<div><span style="white-space: pre;"> </span>{</div>
<div><span style="white-space: pre;"> </span>return field.hashCode() + attribute.hashCode();</div>
<div><span style="white-space: pre;"> </span>}</div>
<div><span style="white-space: pre;"> </span>@Override</div>
<div><span style="white-space: pre;"> </span>public String toString()</div>
<div><span style="white-space: pre;"> </span>{</div>
<div><span style="white-space: pre;"> </span>return field + &#8221; &#8221; + attribute;</div>
<div><span style="white-space: pre;"> </span>}</div>
<div>}</div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://techiedrill.com/2009/11/java-annotations/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java ScriptEngineManager</title>
		<link>http://techiedrill.com/2009/11/java-scriptenginemanager/</link>
		<comments>http://techiedrill.com/2009/11/java-scriptenginemanager/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 07:39:07 +0000</pubDate>
		<dc:creator>karnamrajesh</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[engine]]></category>
		<category><![CDATA[manager]]></category>
		<category><![CDATA[script]]></category>

		<guid isPermaLink="false">http://techiedrill.com/?p=448</guid>
		<description><![CDATA[ScriptEngineManager implements ScriptEngine classes. ScriptEngineManager holds key and value pair and stores the state of an object which is shared the engines created by the Manager. ScriptEngineManager uses the service provider technique to itemize implementations of ScriptEngineFactory.
Binding between the key and value pairs are traditionally referred to as the &#8220;Global Scope&#8221; that is available to [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">ScriptEngineManager implements ScriptEngine classes. ScriptEngineManager holds key and value pair and stores the state of an object which is shared the engines created by the Manager. ScriptEngineManager uses the service provider technique to itemize implementations of ScriptEngineFactory.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">Binding between the key and value pairs are traditionally referred to as the &#8220;Global Scope&#8221; that is available to all instances of ScriptEngine created by theScriptEngineManager. Value binded with the keys are made available to all the scripts.</div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">ScriptEngineManager offers a method which returns arrays of these factories that includes few utilities on basis of mime type, languate name and file extensions.</div>
<p>ScriptEngineManager implements ScriptEngine classes. ScriptEngineManager holds key and value pair and stores the state of an object which is shared the engines created by the Manager. ScriptEngineManager uses the service provider technique to itemize implementations of ScriptEngineFactory.</p>
<p>Binding between the key and value pairs are traditionally referred to as the &#8220;Global Scope&#8221; that is available to all instances of ScriptEngine created by theScriptEngineManager. Value binded with the keys are made available to all the scripts.</p>
<p>ScriptEngineManager offers a method which returns arrays of these factories that includes few utilities on basis of mime type, languate name and file extensions.</p>
<p><em>import javax.script.*;</em></p>
<p><em>import java.io.*;</em></p>
<p><em>public class FileScript</em></p>
<p><em>{</em></p>
<p><span style="white-space:pre"><em> </em></span><em>public static void main(String args[])</em></p>
<p><span style="white-space:pre"><em> </em></span><em>{</em></p>
<p><span style="white-space:pre"><em> </em></span><em>ScriptEngineManager manager = new ScriptEngineManager();</em></p>
<p><span style="white-space:pre"><em> </em></span><em>ScriptEngine engine = manager.getEngineByName(&#8221;javascript&#8221;);</em></p>
<p><em><br />
</em></p>
<p><span style="white-space:pre"><em> </em></span><em>/*if(args.length!=1)</em></p>
<p><span style="white-space:pre"><em> </em></span><em>{</em></p>
<p><span style="white-space:pre"><em> </em></span><em>System.out.print(&#8221;Insufficient arguments&#8221;);</em></p>
<p><span style="white-space:pre"><em> </em></span><em>System.exit(0);</em></p>
<p><span style="white-space:pre"><em> </em></span><em>}*/</em></p>
<p><em><br />
</em></p>
<p><span style="white-space:pre"><em> </em></span><em>FileReader reader = null;</em></p>
<p><span style="white-space:pre"><em> </em></span><em>try</em></p>
<p><span style="white-space:pre"><em> </em></span><em>{</em></p>
<p><span style="white-space:pre"><em> </em></span><em>reader = new FileReader(args[0]);</em></p>
<p><span style="white-space:pre"><em> </em></span><em>}</em></p>
<p><span style="white-space:pre"><em> </em></span><em>catch(FileNotFoundException e1)</em></p>
<p><span style="white-space:pre"><em> </em></span><em>{</em></p>
<p><span style="white-space:pre"><em> </em></span><em>e1.printStackTrace();</em></p>
<p><span style="white-space:pre"><em> </em></span><em>}</em></p>
<p><span style="white-space:pre"><em> </em></span><em>try</em></p>
<p><span style="white-space:pre"><em> </em></span><em>{</em></p>
<p><span style="white-space:pre"><em> </em></span><em>engine.eval(reader);</em></p>
<p><span style="white-space:pre"><em> </em></span><em>}</em></p>
<p><span style="white-space:pre"><em> </em></span><em>catch(ScriptException e)</em></p>
<p><span style="white-space:pre"><em> </em></span><em>{</em></p>
<p><span style="white-space:pre"><em> </em></span><em>e.printStackTrace();</em></p>
<p><span style="white-space:pre"><em> </em></span><em>}</em></p>
<p><span style="white-space:pre"><em> </em></span><em>}</em></p>
<p><em>}</em></p>
<p><em>Note: Take the below code and save it as sample.js extension and run the above java code with the sample.js as run time argument for java interpreter </em></p>
<p><em><strong>Eg: java FileScript sample.js</strong></em></p>
<p><em>function hello()</p>
<p>{</p>
<p>println(&#8221;Hello from Function&#8221;);</p>
<p>}</p>
<p>for(i=0;i&lt;5;i++)</p>
<p>{</p>
<p><span style="white-space: pre;"> </span>print((i+1) + &#8221; &#8221; )</p>
<p><span style="white-space: pre;"> </span>hello()</p>
<p>}</p>
<p></em></p>
]]></content:encoded>
			<wfw:commentRss>http://techiedrill.com/2009/11/java-scriptenginemanager/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Creating Folders using simple Java</title>
		<link>http://techiedrill.com/2009/11/creating-folders-using-simple-java/</link>
		<comments>http://techiedrill.com/2009/11/creating-folders-using-simple-java/#comments</comments>
		<pubDate>Sun, 22 Nov 2009 07:21:29 +0000</pubDate>
		<dc:creator>karnamrajesh</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[create]]></category>
		<category><![CDATA[folder]]></category>
		<category><![CDATA[simple]]></category>

		<guid isPermaLink="false">http://techiedrill.com/?p=446</guid>
		<description><![CDATA[import java.io.*;
class FileEx
{
 public static void main(String [] s) throws IOException
 {
// File f = new File(&#8221;xyz.txt&#8221;);
// f.delete();
 File f1 = new File(s[0]);
 f1.mkdir();
 File f2 = new File (f1,s[1]);
 f2.mkdir();
 File f3 = new File (f2,s[2]);
 f3.mkdir();
 if(f3.mkdir())
 {
 System.out.println(&#8221;Folder Created&#8230;.&#8221;);
 File ff = new File(f3,&#8221;akshatha.txt&#8221;);
 ff.createNewFile();
 }
 else
 {
 System.out.println(&#8221;folder already exists&#8230;&#8221;);
 }
 [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><em>import java.io.*;</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><em>class FileEx</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><em>{</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>public static void main(String [] s) throws IOException</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>{</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><em>//</em><span style="white-space: pre;"><em> </em></span><em>File f = new File(&#8221;xyz.txt&#8221;);</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><em>//</em><span style="white-space: pre;"><em> </em></span><em>f.delete();</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>File f1 = new File(s[0]);</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>f1.mkdir();</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>File f2 = new File (f1,s[1]);</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>f2.mkdir();</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>File f3 = new File (f2,s[2]);</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>f3.mkdir();</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>if(f3.mkdir())</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>{</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>System.out.println(&#8221;Folder Created&#8230;.&#8221;);</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>File ff = new File(f3,&#8221;akshatha.txt&#8221;);</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>ff.createNewFile();</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>}</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>else</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>{</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>System.out.println(&#8221;folder already exists&#8230;&#8221;);</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>}</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><span style="white-space: pre;"><em> </em></span><em>}</em></div>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 0px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;"><em>}</em></div>
<p>It is quite easy to create folders using Java File concepts. Using java.io.file package we can create folders using mkdir(make directory) method. This can also handle folder already exists scenarios.</p>
<p>At the same time of creating folders it is also possible to create files of any extensions.</p>
<p>Try out the below sample code and explore things&#8230;</p>
<p><em>import java.io.*;</em></p>
<p><em>class FileEx</em></p>
<p><em>{</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>public static void main(String [] s) throws IOException</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>{</em></p>
<p><em>//</em><span style="white-space: pre;"><em> </em></span><em>File f = new File(&#8221;xyz.txt&#8221;);</em></p>
<p><em>//</em><span style="white-space: pre;"><em> </em></span><em>f.delete();</em></p>
<p><em><br />
</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>File f1 = new File(s[0]);</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>f1.mkdir();</em></p>
<p><em><br />
</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>File f2 = new File (f1,s[1]);</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>f2.mkdir();</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>File f3 = new File (f2,s[2]);</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>f3.mkdir();</em></p>
<p><em><br />
</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>if(f3.mkdir())</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>{</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>System.out.println(&#8221;Folder Created&#8230;.&#8221;);</em></p>
<p><em><br />
</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>File ff = new File(f3,&#8221;sample.txt&#8221;);</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>ff.createNewFile();</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>}</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>else</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>{</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>System.out.println(&#8221;folder already exists&#8230;&#8221;);</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>}</em></p>
<p><span style="white-space: pre;"><em> </em></span><em>}</em></p>
<p><em>}</em></p>
]]></content:encoded>
			<wfw:commentRss>http://techiedrill.com/2009/11/creating-folders-using-simple-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
