<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;DUADRHo9fyp7ImA9WhRbFk4.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900</id><updated>2012-02-07T23:32:55.467+05:30</updated><title>Simple and Easy Codes</title><subtitle type="html">Here you will find simplified codes related to java/j2ee, JavaScript, HTMl, XML, Linux / UNIX, Databases like MS SQL, Oracle, DB2 etc. Also it contains Solutions to various Errors and Exceptions.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://www.simpleandeasycodes.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>163</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/SimpleAndEasyCodes" /><feedburner:info uri="simpleandeasycodes" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;DUEDSHc6cSp7ImA9WhRbFk4.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-2479453098999444938</id><published>2012-02-07T23:31:00.000+05:30</published><updated>2012-02-07T23:31:19.919+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-02-07T23:31:19.919+05:30</app:edited><title>Java Threads - Wait and Notify Example</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span style="font-family: inherit;"&gt;&lt;span style="background-color: rgba(255, 255, 255, 0.917969); color: #222222; text-align: -webkit-auto;"&gt;This is a simple Thread example which demonstrates wait and notify functionality of a Thread. In this example we have a main class i.e. MainThread which will call AnotherThread, so that you can see both running simultaneously. Now our main thread enters into wait state till AnotherThread notifies it.&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: rgba(255, 255, 255, 0.917969); color: #222222; text-align: -webkit-auto;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: rgba(255, 255, 255, 0.917969); color: #222222; text-align: -webkit-auto;"&gt;&lt;span style="font-family: inherit;"&gt;Please see the self explanatory code. Directly you can this code and see the output.&lt;/span&gt;&lt;/span&gt; &lt;br /&gt;
&lt;span style="background-color: rgba(255, 255, 255, 0.917969); color: #222222; text-align: -webkit-auto;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: rgba(255, 255, 255, 0.917969); text-align: -webkit-auto;"&gt;&lt;span style="color: #222222; font-size: large;"&gt;&lt;b&gt;MainThread.java&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: rgba(255, 255, 255, 0.917969); text-align: -webkit-auto;"&gt;&lt;span style="color: #222222; font-size: large;"&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="background-color: rgba(255, 255, 255, 0.917969); text-align: -webkit-auto;"&gt;&lt;span style="color: #222222;"&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;/* MainThread.java */&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;public class MainThread {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;public static void main(String[] args) {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;//Start another thread&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;Thread anotherThreadObject = new Thread(new AnotherThread());&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;anotherThreadObject.start();&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;//Main thread continues&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;for(int i=0;i&amp;lt;10;i++) {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;System.out.println(Thread.currentThread().getName()+" : "+i);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;//this thread halts for 500 millisecond&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;try {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;Thread.sleep(1 * 500);&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;} catch (InterruptedException e) {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;e.printStackTrace();&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;//when counter reaches 5 wait for Other thread to notify it&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;if(i == 5) {&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;try {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;     &lt;/span&gt;synchronized(MainThread.class) {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;      &lt;/span&gt;System.out.println("MainThread is Waiting....");&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;      &lt;/span&gt;MainThread.class.wait();&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;     &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;} catch (InterruptedException e) {&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;     &lt;/span&gt;e.printStackTrace();&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}//for&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;}//main&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="font-weight: bold;"&gt;&lt;span style="color: #222222;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style="font-weight: bold;"&gt;&lt;span style="color: #222222;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style="font-weight: bold;"&gt;&lt;span style="color: #222222;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;AnotherThread.java&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-size: large;"&gt;&lt;b&gt;&lt;br /&gt;
&lt;/b&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;/*&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;AnotherThread.java&lt;/span&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&lt;/span&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;*/&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;public class AnotherThread implements Runnable {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;public void run() {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;for(int i=0;i&amp;lt;10;i++) {&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;System.out.println(Thread.currentThread().getName()+" : "+i);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;   &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;//this thread halts for 1 second&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;try {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;Thread.sleep(1 * 1000);&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;} catch (InterruptedException e) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;    &lt;/span&gt;e.printStackTrace();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;  &lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;//Now notify the main thread.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;synchronized(MainThread.class) {&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;System.out.println("AnotherThread Notifying MainThread....");&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;   &lt;/span&gt;MainThread.class.notify();&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt;  &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;span class="Apple-tab-span" style="white-space: pre;"&gt; &lt;/span&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-weight: bold;"&gt;&lt;span style="color: #222222;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div style="font-weight: bold;"&gt;&lt;span style="color: #222222;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;&lt;div style="font-weight: bold;"&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-size: large;"&gt;Output&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-weight: bold;"&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-size: large;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="separator" style="clear: both; text-align: center;"&gt;&lt;span style="color: #222222;"&gt;&lt;a href="http://3.bp.blogspot.com/-k9ICerimggo/TzFmth508CI/AAAAAAAAA0A/fBX4q0Go2eQ/s1600/Thread+Output.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://3.bp.blogspot.com/-k9ICerimggo/TzFmth508CI/AAAAAAAAA0A/fBX4q0Go2eQ/s1600/Thread+Output.jpg" /&gt;&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-weight: bold;"&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-size: large;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-weight: bold;"&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-size: large;"&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;div class="MsoNormal" style="font-family: arial, sans-serif; font-size: 13px;"&gt;&lt;span style="color: #222222;"&gt;&lt;b&gt;Note : &lt;/b&gt;&lt;span style="font-weight: normal;"&gt;you may get below mentioned error, if you do not add synchronized block before calling wait menthod.&lt;u&gt;&lt;/u&gt;&lt;u&gt;&lt;/u&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="font-family: arial, sans-serif; font-size: 13px; font-weight: normal;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div class="MsoNormal" style="font-size: 13px; font-weight: normal;"&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;Exception in thread "main" java.lang.&lt;wbr&gt;&lt;/wbr&gt;IllegalMonitorStateException&lt;u&gt;&lt;/u&gt;&lt;u&gt;&lt;/u&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="font-size: 13px; font-weight: normal;"&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.lang.Object.wait(Native Method)&lt;u&gt;&lt;/u&gt;&lt;u&gt;&lt;/u&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="font-size: 13px; font-weight: normal;"&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.lang.Object.wait(Object.&lt;wbr&gt;&lt;/wbr&gt;java:485)&lt;u&gt;&lt;/u&gt;&lt;u&gt;&lt;/u&gt;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div class="MsoNormal" style="font-size: 13px; font-weight: normal;"&gt;&lt;span style="color: #222222;"&gt;&lt;span style="font-family: 'Courier New', Courier, monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at test.MainThread.main(&lt;wbr&gt;&lt;/wbr&gt;MainThread.java:25)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-2479453098999444938?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/iUBOUTXVnP_R96rpR3LBLnucHM0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/iUBOUTXVnP_R96rpR3LBLnucHM0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/iUBOUTXVnP_R96rpR3LBLnucHM0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/iUBOUTXVnP_R96rpR3LBLnucHM0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/WD6nu05DRaU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/2479453098999444938/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2012/02/java-threads-wait-and-notify-example.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/2479453098999444938?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/2479453098999444938?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/WD6nu05DRaU/java-threads-wait-and-notify-example.html" title="Java Threads - Wait and Notify Example" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://3.bp.blogspot.com/-k9ICerimggo/TzFmth508CI/AAAAAAAAA0A/fBX4q0Go2eQ/s72-c/Thread+Output.jpg" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2012/02/java-threads-wait-and-notify-example.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUYCQXo9fCp7ImA9WhRVF0U.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-4525972193617164626</id><published>2012-01-17T13:29:00.000+05:30</published><updated>2012-01-17T13:29:20.464+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-17T13:29:20.464+05:30</app:edited><title>java.net.ConnectException: Connection timed out: connect</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;Exception in thread "main" java.net.ConnectException: Connection timed out: connect&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.net.PlainSocketImpl.socketConnect(Native Method)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.net.PlainSocketImpl.doConnect(PlainSocketImpl.java:333)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.net.PlainSocketImpl.connectToAddress(PlainSocketImpl.java:195)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:182)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:366)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.net.Socket.connect(Socket.java:529)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.net.Socket.connect(Socket.java:478)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at sun.net.NetworkClient.doConnect(NetworkClient.java:163)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at sun.net.www.http.HttpClient.openServer(HttpClient.java:394)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at sun.net.www.http.HttpClient.openServer(HttpClient.java:529)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at sun.net.www.http.HttpClient.&lt;init&gt;(HttpClient.java:233)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at sun.net.www.http.HttpClient.New(HttpClient.java:306)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at sun.net.www.http.HttpClient.New(HttpClient.java:323)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at sun.net.www.protocol.http.HttpURLConnection.getNewHttpClient(HttpURLConnection.java:860)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at sun.net.www.protocol.http.HttpURLConnection.plainConnect(HttpURLConnection.java:801)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at sun.net.www.protocol.http.HttpURLConnection.connect(HttpURLConnection.java:726)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1049)&lt;/init&gt;&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: inherit;"&gt;If you get above error, there could be one of the following reasons.&lt;br /&gt;
&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;ul style="text-align: left;"&gt;&lt;li&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: inherit;"&gt;The domain/IP or port is incorrect&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: inherit;"&gt;The domain/IP or port (i.e service) is down&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: inherit;"&gt;The domain/IP is taking longer than your default timeout to respond&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: inherit;"&gt;You have a firewall that is blocking requests or responses on whatever port you are using&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: inherit;"&gt;You have a firewall that is blocking requests to that particular host&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;li&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: inherit;"&gt;Your internet connection is down&lt;/span&gt;&lt;/span&gt;&lt;/li&gt;
&lt;/ul&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: inherit;"&gt;&lt;br /&gt;
I most of the cases there is a firewalls issue. Firewalls and port or IP blocking may be in place by your ISP. &lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: black;"&gt;&lt;span style="font-family: inherit;"&gt;To access URL via Firewalls, you may require to set http.proxyHost and http.proxyPort. Try using below syntax.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;System.setProperty("http.proxyHost", "host name");&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;System.setProperty("http.proxyPort", "port number");&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Some time you may also get below error.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;Exception in thread "main" java.io.IOException: Server returned HTTP response code: 403 for URL: http://www.google.com&lt;/span&gt;&lt;br style="color: blue; font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;" /&gt;&lt;span style="color: blue; font-family: Georgia,&amp;quot;Times New Roman&amp;quot;,serif;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at sun.net.www.protocol.http.HttpURLConnection.getInputStream(HttpURLConnection.java:1313)&lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;br /&gt;
Here you may require to set User-Agent using below syntax.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;connection.addRequestProperty("User-Agent", "Mozilla/4.0");&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Please find the complete code below.&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: black;"&gt;/* SimpleURLConnection.java */&lt;br /&gt;
&lt;br /&gt;
import java.net.*;&lt;br /&gt;
import java.io.*;&lt;br /&gt;
&lt;br /&gt;
public class SimpleURLConnection&lt;br /&gt;
{&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String[] args) throws Exception&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.setProperty("http.proxyHost", "host name");&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.setProperty("http.proxyPort", "port number");&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; URL url= new URL("http://www.google.com");//provide proper url&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; URLConnection connection = url.openConnection();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; connection.addRequestProperty("User-Agent", "Mozilla/4.0");&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; BufferedReader in = new BufferedReader(new InputStreamReader(connection.getInputStream()));&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String line = "";&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; while((line=in.readLine()) != null)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(line);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //closing resource&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; in.close();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; connection=null;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
}&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-4525972193617164626?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/tj8-BQMaH1qjTw6TZB4bUU8Tu14/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tj8-BQMaH1qjTw6TZB4bUU8Tu14/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/tj8-BQMaH1qjTw6TZB4bUU8Tu14/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/tj8-BQMaH1qjTw6TZB4bUU8Tu14/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/l-X9UkiGfp8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/4525972193617164626/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2012/01/javanetconnectexception-connection.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/4525972193617164626?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/4525972193617164626?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/l-X9UkiGfp8/javanetconnectexception-connection.html" title="java.net.ConnectException: Connection timed out: connect" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2012/01/javanetconnectexception-connection.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEABRX48fSp7ImA9WhRVFEs.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-1075373259133973932</id><published>2012-01-13T19:22:00.000+05:30</published><updated>2012-01-13T19:22:34.075+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-13T19:22:34.075+05:30</app:edited><title>Java : Compare two files</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Other day I was required to compare contents of two files in Java. Lets see how to compare two txt files in Java?&lt;br /&gt;
&lt;br /&gt;
I was wondering if there is a Java APIs for Text file comparison, which will compare contents of two txt files using java program. &lt;br /&gt;
&lt;br /&gt;
Basically the java program should mimc the behaviour of diff command of LINUX. diff is a file comparison utility that outputs the differences between two files. It is typically used to show the changes between one version of a file and a former version of the same file. Diff displays the changes made per line for text files.&lt;br /&gt;
&lt;br /&gt;
Output of the java program should give same as result produced by diff command. I got many codes on net but they were not working as expected. Latter i got an idea, why not we can use diff command in our java program to produce the same result. But diff command works for LINUX, what is equivalent for Windows? Well i found COMP or FC are equivalent windows command for diff in LINUX. So with the help of these commands we can build a JAVA program which will compare contents of two txt files.&lt;br /&gt;
&lt;br /&gt;
Lets see the code.&lt;br /&gt;
&lt;br /&gt;
No need to add any jar file, directly you can run this code and see the output.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;/* CompareFiles.java */&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;import java.io.BufferedReader;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;import java.io.InputStreamReader;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;public class CompareFiles {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void compare(String file1,String file2) {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //For Windows&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; runSystemCommand("fc /N \""+file1+"\" \""+file2+"\"");&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //For UNIX / LINUX&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //runSystemCommand("diff "+file1+" "+file2);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public void runSystemCommand(String command) {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Process proc = Runtime.getRuntime().exec(command);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BufferedReader inputStream = new BufferedReader(new InputStreamReader(proc.getInputStream()));&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BufferedReader errorStream = new BufferedReader(new InputStreamReader(proc.getErrorStream()));&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; String strLn = "";&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // reading output stream of the command&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while ((strLn = inputStream.readLine()) != null) {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(strLn);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; // reading errors of the command (if any)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while ((strLn = errorStream.readLine()) != null) {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println(strLn);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; } catch (Exception e) {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.printStackTrace();&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String[] args) {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; CompareFiles cf = new CompareFiles();&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; cf.compare("C:\\file1.txt","C:\\file2.txt");&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;}&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-1075373259133973932?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/cGWW2fGtktA5Jci31Hfkxki4XiA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/cGWW2fGtktA5Jci31Hfkxki4XiA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/cGWW2fGtktA5Jci31Hfkxki4XiA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/cGWW2fGtktA5Jci31Hfkxki4XiA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/37ISG9uJ-f4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/1075373259133973932/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2012/01/java-compare-two-files.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/1075373259133973932?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/1075373259133973932?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/37ISG9uJ-f4/java-compare-two-files.html" title="Java : Compare two files" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2012/01/java-compare-two-files.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ck4GQ3g6eip7ImA9WhRVFEg.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-1370542950736390364</id><published>2012-01-13T16:05:00.000+05:30</published><updated>2012-01-13T16:05:22.612+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-13T16:05:22.612+05:30</app:edited><title>UNIX / LINUX - HELP diff Command</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;NAME&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; diff - compare two files&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;SYNOPSIS&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; diff [-bitw] [-c | -e | -f | -h | -n | -u]&amp;nbsp; file1 file2&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; diff [-bitw] [-C number | -U number]&amp;nbsp; file1 file2&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; diff [-bitw] [-D string] file1 file2&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; diff [-bitw] [-c | -e | -f | -h | -n | -u]&amp;nbsp; [-l]&amp;nbsp; [-r]&amp;nbsp; [-s] [-S name] directory1 directory2&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;DESCRIPTION&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The diff utility will compare&amp;nbsp; the&amp;nbsp; contents&amp;nbsp; of&amp;nbsp; file1&amp;nbsp; and file2&amp;nbsp; and write to standard output a list of changes necessary to convert&amp;nbsp; file1&amp;nbsp; into&amp;nbsp; file2.&amp;nbsp; This&amp;nbsp; list&amp;nbsp; should&amp;nbsp; be minimal.&amp;nbsp;&amp;nbsp; Except&amp;nbsp; in rare circumstances, diff finds a smallest sufficient set of file differences. No output&amp;nbsp; will&amp;nbsp; be produced if the files are identical.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The normal output contains lines of these forms:&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n1 a n3,n4&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n1,n2 d n3&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; n1,n2 c n3,n4&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; where n1&amp;nbsp; and&amp;nbsp; n2&amp;nbsp; represent&amp;nbsp; lines&amp;nbsp; file1&amp;nbsp; and&amp;nbsp; n3&amp;nbsp; and&amp;nbsp; n4 represent lines in file2 These lines resemble ed(1) commands to convert file1 to file2. By exchanging a for d and reading backward, file2 can be converted to file1. As in ed, identical pairs, where n1=n2 or n3=n4, are abbreviated as a single number.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Following each of these lines come all the&amp;nbsp; lines&amp;nbsp; that&amp;nbsp; are affected&amp;nbsp; in&amp;nbsp; the&amp;nbsp; first&amp;nbsp; file&amp;nbsp; flagged by `&amp;lt;', then all the lines that are affected in the second file flagged by `&amp;gt;'.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;OPTIONS&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The following options are supported:&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -b&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Ignores trailing blanks&amp;nbsp; (spaces&amp;nbsp; and&amp;nbsp; tabs) and&amp;nbsp;&amp;nbsp; treats&amp;nbsp; other&amp;nbsp; strings&amp;nbsp; of&amp;nbsp; blanks&amp;nbsp; as equivalent.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -i&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Ignores the case of&amp;nbsp; letters.&amp;nbsp; For&amp;nbsp; example, 'A' will compare equal to 'a'.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -t&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Expands &lt;tab&gt; characters&amp;nbsp; in&amp;nbsp; output&amp;nbsp; lines. Normal or -c output adds character(s) to the front of each line that may adversely affect the indentation of the original source lines and&amp;nbsp; make&amp;nbsp; the&amp;nbsp; output&amp;nbsp; lines&amp;nbsp; difficult&amp;nbsp; to interpret.&amp;nbsp; This&amp;nbsp; option&amp;nbsp; will&amp;nbsp; preserve the original source's indentation.&lt;/tab&gt;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -w&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Ignores all blanks (&lt;space&gt; and &lt;tab&gt;&amp;nbsp; characters)&amp;nbsp; and&amp;nbsp; treats&amp;nbsp; all&amp;nbsp; other&amp;nbsp; strings of blanks&amp;nbsp;&amp;nbsp; as&amp;nbsp;&amp;nbsp; equivalent.&amp;nbsp;&amp;nbsp;&amp;nbsp; For&amp;nbsp;&amp;nbsp;&amp;nbsp; example, 'if ( a == b )'&amp;nbsp;&amp;nbsp; will&amp;nbsp;&amp;nbsp; compare&amp;nbsp;&amp;nbsp; equal&amp;nbsp; to 'if(a==b)'.&lt;/tab&gt;&lt;/space&gt;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The following options are mutually exclusive:&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -c&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Produces a listing of differences with three lines&amp;nbsp; of&amp;nbsp; context. With this option, output format is modified slightly. That is, output begins&amp;nbsp; with&amp;nbsp; identification&amp;nbsp; of&amp;nbsp; the&amp;nbsp; files involved and their creation dates, then each change&amp;nbsp; is&amp;nbsp; separated by a line with a dozen *'s. The lines removed from file1 are marked with&amp;nbsp; '-'.&amp;nbsp; The&amp;nbsp; lines&amp;nbsp; added&amp;nbsp; to&amp;nbsp; file2 are marked '+'. Lines that are changed from&amp;nbsp; one file&amp;nbsp; to&amp;nbsp; the other are marked in both files with '!'.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -C number&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Produces a listing of differences&amp;nbsp; identical to&amp;nbsp; that produced by -c with number lines of context.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -D string&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Creates a merged version of file1 and&amp;nbsp; file2 with&amp;nbsp; C&amp;nbsp; preprocessor&amp;nbsp; controls&amp;nbsp; included so that a compilation&amp;nbsp; of&amp;nbsp; the&amp;nbsp; result&amp;nbsp; without defining&amp;nbsp; string&amp;nbsp; is equivalent to compiling file1,&amp;nbsp; while&amp;nbsp; defining&amp;nbsp; string&amp;nbsp; will&amp;nbsp; yield file2.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -e&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Produces a script of only a, c, and&amp;nbsp; d&amp;nbsp; commands for the editor ed, which will recreate file2 from file1. In connection with the&amp;nbsp; -e option, the following shell program may help maintain multiple versions of a&amp;nbsp; file.&amp;nbsp; Only an&amp;nbsp; ancestral&amp;nbsp; file&amp;nbsp; ($1)&amp;nbsp; and&amp;nbsp; a&amp;nbsp; chain&amp;nbsp; of version-to-version&amp;nbsp; ed&amp;nbsp; scripts&amp;nbsp; ($2,$3,...) made&amp;nbsp; by&amp;nbsp; diff&amp;nbsp; need&amp;nbsp; be on hand. A ``latest version'' appears on the standard output. (shift; cat $*; echo '1,$p') | ed - $1&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -f&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Produces a similar script, not&amp;nbsp; useful&amp;nbsp; with ed, in the opposite order.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -h&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Does a fast, half-hearted job. It works only when&amp;nbsp; changed&amp;nbsp; stretches&amp;nbsp; are short and well separated, but does work on files of&amp;nbsp; unlimited length. Options -c, -C, -D, -e, -f, and -n are unavailable with -h.&amp;nbsp; diff&amp;nbsp; does&amp;nbsp; not descend into directories with this option.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -n&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Produces a script similar to -e, but in&amp;nbsp; the opposite&amp;nbsp; order&amp;nbsp; and with a count of changed lines on each insert or delete command.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -u&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Produces a listing of differences with three lines&amp;nbsp; of&amp;nbsp; context. The output is similar to that of the -c option, except that the&amp;nbsp; context is "unified". Removed and changed lines in file1 are marked by&amp;nbsp; a&amp;nbsp; '-'&amp;nbsp; while&amp;nbsp; lines added&amp;nbsp; or&amp;nbsp; changed&amp;nbsp; in file2 are marked by a '+'. Both versions of changed&amp;nbsp; lines&amp;nbsp; appear in&amp;nbsp; the&amp;nbsp; output,&amp;nbsp; while&amp;nbsp; added, removed, and context lines appear only once. The identification&amp;nbsp; of&amp;nbsp; file1&amp;nbsp; and&amp;nbsp; file2 is different, with "---" and&amp;nbsp; "+++"&amp;nbsp; being&amp;nbsp; printed&amp;nbsp; where "***"&amp;nbsp; and&amp;nbsp; "---"&amp;nbsp; would&amp;nbsp; appear with the -c option. Each change is separated by&amp;nbsp; a&amp;nbsp; line of the form @@ -n1,n2 +n3,n4 @@&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -U number&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Produces a listing of differences&amp;nbsp; identical to&amp;nbsp; that produced by -u with number lines of context.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The following options are used for comparing directories:&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -l&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Produces output in long format.&amp;nbsp; Before&amp;nbsp; the diff,&amp;nbsp; each text file is piped through pr(1) to&amp;nbsp; paginate&amp;nbsp; it.&amp;nbsp;&amp;nbsp; Other&amp;nbsp; differences&amp;nbsp;&amp;nbsp; are remembered&amp;nbsp; and&amp;nbsp; summarized&amp;nbsp; after&amp;nbsp; all text file differences are reported. &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -r&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Applies diff recursively to common subdirectories encountered.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -s&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Reports&amp;nbsp; files&amp;nbsp; that&amp;nbsp; are&amp;nbsp; identical.&amp;nbsp; These identical&amp;nbsp; files would not otherwise be mentioned.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; -S name&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Starts&amp;nbsp; a&amp;nbsp; directory&amp;nbsp; diff&amp;nbsp; in&amp;nbsp; the&amp;nbsp; middle, beginning with the file name.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;OPERANDS&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The following operands are supported:&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; file1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A path name of a file&amp;nbsp; or&amp;nbsp; directory&amp;nbsp; to&amp;nbsp; be&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; file2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; compared. If either file1 or file2 is -, the standard input will be used in its place.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; directory1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; A path name of a directory to be compared.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; directory2&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; If only one of file1 and file2 is a directory, diff will&amp;nbsp; be applied&amp;nbsp; to the non-directory file and the file contained in the directory file with a filename that is the same&amp;nbsp; as&amp;nbsp; the last component of the non-directory file.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;USAGE&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; See largefile(5) for the description of the behavior of diff&amp;nbsp; when encountering files greater than or equal to 2 Gbyte ( 2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; **31 bytes).&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;EXAMPLES&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Example 1: Typical output of the diff command&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; In the following command, dir1 is a directory&amp;nbsp; containing&amp;nbsp; a directory&amp;nbsp; named&amp;nbsp; x, dir2 is a directory containing a directory named x, dir1/x and dir2/x&amp;nbsp; both&amp;nbsp; contain&amp;nbsp; files&amp;nbsp; named date.out, and dir2/x contains a file named y:&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; example% diff -r dir1 dir2&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Common subdirectories: dir1/x and dir2/x&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Only in dir2/x: y&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; diff -r dir1/x/date.out dir2/x/date.out&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1c1&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt; Mon Jul&amp;nbsp; 2 13:12:16 PDT 1990&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ---&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt; Tue Jun 19 21:41:39 PDT 1990&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;ENVIRONMENT VARIABLES&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; See environ(5) for descriptions of the following environment variables&amp;nbsp; that&amp;nbsp; affect the execution of diff: LANG, LC_ALL, LC_CTYPE, LC_MESSAGES, LC_TIME, and NLSPATH.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; TZ&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Determines the locale for&amp;nbsp; affecting&amp;nbsp; the&amp;nbsp; timezone used&amp;nbsp; for&amp;nbsp; calculating file timestamps written with the -C and -c options.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;EXIT STATUS&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; The following exit values are returned:&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; No differences were found.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Differences were found.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; An error occurred.&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;FILES&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /tmp/d?????&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; temporary file used for comparison&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; /usr/lib/diffh&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; executable file for -h option&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;ATTRIBUTES&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; See attributes(5) for descriptions of the&amp;nbsp; following&amp;nbsp; attributes:&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ____________________________________________________________&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ATTRIBUTE TYPE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ATTRIBUTE VALUE&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; |_____________________________|_____________________________|&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; | Availability&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | SUNWesu&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; |_____________________________|_____________________________|&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; | CSI&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | Enabled&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; |_____________________________|_____________________________|&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; | Interface Stability&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; | Standard&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; |&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; |_____________________________|_____________________________|&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;SEE ALSO&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; bdiff(1), cmp(1), comm(1), dircmp(1), ed(1),&amp;nbsp; pr(1),&amp;nbsp; sdiff(1), attributes(5), environ(5), largefile(5), standards(5)&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;NOTES&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Editing scripts produced under the&amp;nbsp; -e&amp;nbsp; or&amp;nbsp; -f&amp;nbsp; options&amp;nbsp; are naive&amp;nbsp; about&amp;nbsp; creating&amp;nbsp; lines&amp;nbsp; consisting of a single period (.).&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Missing NEWLINE at end of file indicates that the last&amp;nbsp; line of the file in question did not have a NEWLINE. If the lines are different, they will be flagged and output, although the output will seem to indicate they are the same.&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-1370542950736390364?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/3SgLCO7wpgvcyURAwUI1O1kvHNs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3SgLCO7wpgvcyURAwUI1O1kvHNs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/3SgLCO7wpgvcyURAwUI1O1kvHNs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3SgLCO7wpgvcyURAwUI1O1kvHNs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/pq14FIm7Pu0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/1370542950736390364/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2012/01/unix-linux-help-diff-command.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/1370542950736390364?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/1370542950736390364?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/pq14FIm7Pu0/unix-linux-help-diff-command.html" title="UNIX / LINUX - HELP diff Command" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2012/01/unix-linux-help-diff-command.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0cASHk6eyp7ImA9WhRVFEg.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-4782456564932627045</id><published>2012-01-13T15:44:00.003+05:30</published><updated>2012-01-13T16:07:29.713+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-13T16:07:29.713+05:30</app:edited><title>COMP and FC : Windows equivalent of UNIX / LINUX diff command</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;COMP and FC commands can be used as Windows equivalent of UNIX / LINUX &lt;b&gt;diff &lt;/b&gt;command.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-size: large;"&gt;&lt;b&gt;COMP&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Compares the contents of two files or sets of files.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;SYNTAX : &lt;/b&gt;&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;COMP [data1] [data2] [/D] [/A] [/L] [/N=number] [/C] [/OFF[LINE]]&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; data1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Specifies location and name(s) of first file(s) to compare.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; data2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Specifies location and name(s) of second files to compare.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; /D&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Displays differences in decimal format.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; /A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Displays differences in ASCII characters.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; /L&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Displays line numbers for differences.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; /N=number&amp;nbsp; Compares only the first specified number of lines in each file.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; /C&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Disregards case of ASCII letters when comparing files.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; /OFF[LINE] Do not skip files with offline attribute set.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;To compare sets of files, use wildcards in data1 and data2 parameters.&lt;/div&gt;&lt;br /&gt;
&lt;span style="font-size: large;"&gt;FC&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Compares two files or sets of files and displays the differences between them&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;SYNTAX:&lt;/b&gt;&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;FC [/A] [/C] [/L] [/LBn] [/N] [/OFF[LINE]] [/T] [/U] [/W] [/nnnn]&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; [drive1:][path1]filename1 [drive2:][path2]filename2&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;FC /B [drive1:][path1]filename1 [drive2:][path2]filename2&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; /A&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Displays only first and last lines for each set of differences.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; /B&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Performs a binary comparison.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; /C&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Disregards the case of letters.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; /L&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Compares files as ASCII text.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; /LBn&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Sets the maximum consecutive mismatches to the specified&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; number of lines.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; /N&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Displays the line numbers on an ASCII comparison.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; /OFF[LINE] Do not skip files with offline attribute set.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; /T&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Does not expand tabs to spaces.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; /U&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Compare files as UNICODE text files.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; /W&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Compresses white space (tabs and spaces) for comparison.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; /nnnn&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Specifies the number of consecutive lines that must match&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; after a mismatch.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; [drive1:][path1]filename1&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Specifies the first file or set of files to compare.&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; [drive2:][path2]filename2&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Specifies the second file or set of files to compare.&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-4782456564932627045?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/_tNeBBoVqwbdHBe1CvRPxK3ZhXI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_tNeBBoVqwbdHBe1CvRPxK3ZhXI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/_tNeBBoVqwbdHBe1CvRPxK3ZhXI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_tNeBBoVqwbdHBe1CvRPxK3ZhXI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/ZK_hlymAV6Y" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/4782456564932627045/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2012/01/comp-and-fc-windows-equivalent-of-unix.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/4782456564932627045?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/4782456564932627045?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/ZK_hlymAV6Y/comp-and-fc-windows-equivalent-of-unix.html" title="COMP and FC : Windows equivalent of UNIX / LINUX diff command" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2012/01/comp-and-fc-windows-equivalent-of-unix.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0cDRHgzeSp7ImA9WhRVEEQ.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-5642773974028883895</id><published>2012-01-09T14:21:00.000+05:30</published><updated>2012-01-09T14:21:15.681+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-01-09T14:21:15.681+05:30</app:edited><title>Java : Simple LDAP program</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-family: inherit;"&gt;This is a simple LDAP program in java. Here we are using &lt;a href="http://www.idevelopment.info/data/LDAP/Netscape/SDK_Installing_Netscape_SDK_Java_417.shtml" target="_blank"&gt;&lt;b&gt;Netscape Directory SDK&lt;/b&gt;&lt;/a&gt;&lt;/span&gt;.&lt;span style="font-family: inherit;"&gt;To know more about Mozilla Netscape &lt;a href="http://www.mozilla.org/directory/javasdk.html" target="_blank"&gt;click here&lt;/a&gt;. To run this program you need to download &lt;a href="http://www-archive.mozilla.org/directory/javasdk.html" target="_blank"&gt;&lt;b&gt;ldapsdk.jar&lt;/b&gt;&lt;/a&gt; For Example &lt;b&gt;ldapsdk-4.1.jar&lt;/b&gt;&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-family: inherit;"&gt;To download ldapsdk-4.1.jar, &lt;a href="http://mirrors.ibiblio.org/pub/mirrors/maven2/ldapsdk/ldapsdk/4.1/ldapsdk-4.1.jar" target="_blank"&gt;click here&lt;/a&gt;. Provide appropriate data and see the output.&lt;/span&gt;&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;/* TestLDAP.java */&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;import java.util.Enumeration;&lt;br /&gt;
&lt;br /&gt;
import netscape.ldap.LDAPAttribute;&lt;br /&gt;
import netscape.ldap.LDAPAttributeSet;&lt;br /&gt;
import netscape.ldap.LDAPConnection;&lt;br /&gt;
import netscape.ldap.LDAPEntry;&lt;br /&gt;
import netscape.ldap.LDAPException;&lt;br /&gt;
import netscape.ldap.LDAPSearchResults;&lt;br /&gt;
&lt;br /&gt;
public class TestLDAP {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; public static void main(String[] args) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; LDAPConnection ldConnection = null;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; LDAPEntry ldEntry = null;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; try {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ldConnection = new LDAPConnection();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String HOSTNAME = "HOSTNAME";&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; int PORT = 389;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String TREEBASE = "ou=PEOPLE,o=ha";//your DN&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //String QUERY = "(objectclass=* )";&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String QUERY = "(&amp;amp;(objectclass=objclass )(attribute=*value*))";&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ldConnection.connect( HOSTNAME, PORT );&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; //String[] attrNames = {"*"};&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String[] attributeNames = {"val1","val2","val3","val4"};&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; LDAPSearchResults ldSearchResult = ldConnection.search(TREEBASE,LDAPConnection.SCOPE_ONE,QUERY,attributeNames,false);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; if(ldSearchResult.hasMoreElements()) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; ldEntry = ldSearchResult.next();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; LDAPAttributeSet ldAttributeSet = ldEntry.getAttributeSet();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; Enumeration&lt;ldapattribute&gt; enumAttributeSet = ldAttributeSet.getAttributes();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; while(enumAttributeSet.hasMoreElements()) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; LDAPAttribute ldAttribute = enumAttributeSet.nextElement();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String attrName = ldAttribute.getName();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; String[] aVal = ldAttribute.getStringValueArray();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("----------------------");&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("Key&amp;nbsp;&amp;nbsp; : "+attrName);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; for(String val : aVal) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; System.out.println("Value : "+val);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; catch(LDAPException LDAPex) {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; LDAPex.printStackTrace();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
}&lt;br /&gt;
&lt;/ldapattribute&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-5642773974028883895?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/6lpILv-s5jwy_W10CRij0K_XrjY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6lpILv-s5jwy_W10CRij0K_XrjY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/6lpILv-s5jwy_W10CRij0K_XrjY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/6lpILv-s5jwy_W10CRij0K_XrjY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/ocQXX3Mup2A" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/5642773974028883895/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2012/01/java-simple-ldap-program.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/5642773974028883895?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/5642773974028883895?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/ocQXX3Mup2A/java-simple-ldap-program.html" title="Java : Simple LDAP program" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2012/01/java-simple-ldap-program.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUMFSXc9eSp7ImA9WhRXEE4.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-7033628920619513000</id><published>2011-12-16T16:33:00.002+05:30</published><updated>2011-12-16T16:33:38.961+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-16T16:33:38.961+05:30</app:edited><title>SQL0575N  View or materialized query table "SCHEMA.TABLE_NAME" cannot be used because it has been marked inoperative.  SQLSTATE=51024</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;exceptionCOM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver][DB2/SUN64] SQL0575N&amp;nbsp; View or materialized query table "SCHEMA.TABLE_NAME" cannot be used because it has been marked inoperative.&amp;nbsp; SQLSTATE=51024&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;OR&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;51024(-575)[IBM][CLI Driver][DB2/SUN64] SQL0575N&amp;nbsp; View or materialized query table "SCHEMA.TABLE_NAME" cannot be used because it has been marked inoperative.&amp;nbsp; SQLSTATE=51024&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;(0.45 secs)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
If you get above exception in JAVA or while executing query in DB2, possible reason could be the view or materialized query table name has been marked inoperative because a table, view, alias, or privilege upon which it is dependent has been removed.&lt;br /&gt;
&lt;br /&gt;
Please report this error to your database administrator so that they may grant privilege for that table, view or alias.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-7033628920619513000?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/sF2gr4ePbIGsf1i5LbSTWDEoo-g/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sF2gr4ePbIGsf1i5LbSTWDEoo-g/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/sF2gr4ePbIGsf1i5LbSTWDEoo-g/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/sF2gr4ePbIGsf1i5LbSTWDEoo-g/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/kkNk_lP1VPY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/7033628920619513000/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2011/12/sql0575n-view-or-materialized-query.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/7033628920619513000?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/7033628920619513000?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/kkNk_lP1VPY/sql0575n-view-or-materialized-query.html" title="SQL0575N  View or materialized query table &quot;SCHEMA.TABLE_NAME&quot; cannot be used because it has been marked inoperative.  SQLSTATE=51024" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2011/12/sql0575n-view-or-materialized-query.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUUHRHg_fyp7ImA9WhRXEE4.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-8850999302894371094</id><published>2011-12-16T16:30:00.000+05:30</published><updated>2011-12-16T16:30:35.647+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-16T16:30:35.647+05:30</app:edited><title>java.lang.IllegalArgumentException: Illegal pattern character 'AT'</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;I got below mentioned error, while trying to add characters other than pre defined date pattern.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Exception in thread "main" java.lang.IllegalArgumentException: Illegal pattern character 'AT'&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.text.SimpleDateFormat.compile(SimpleDateFormat.java:769)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.text.SimpleDateFormat.initialize(SimpleDateFormat.java:576)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.text.SimpleDateFormat.&lt;init&gt;(SimpleDateFormat.java:501)&lt;/init&gt;&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.text.SimpleDateFormat.&lt;init&gt;(SimpleDateFormat.java:476)&lt;/init&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
To add your desire Characters or String you need to by-pass it using escape sequence. Please see the correct syntax below. Note the escape character single quote ('), whatever you want to pass a Characters or String need to by-pass it using escape character single quote (').&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Correct Syntax:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: red;"&gt;Calendar &lt;/span&gt;cal = &lt;span style="color: red;"&gt;Calendar&lt;/span&gt;.getInstance();&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: red;"&gt;SimpleDateFormat &lt;/span&gt;sdFormat =&amp;nbsp; &lt;span style="color: blue;"&gt;new &lt;/span&gt;&lt;span style="color: red;"&gt;SimpleDateFormat&lt;/span&gt;(&lt;span style="color: magenta;"&gt;"yyyy-MM-dd 'AT' hh:mm:ss"&lt;/span&gt;);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: red;"&gt;String &lt;/span&gt;strDate = sdFormat.format(cal.getTime());&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: red;"&gt;System&lt;/span&gt;.out.println(&lt;span style="color: magenta;"&gt;"Now : "&lt;/span&gt;+strDate);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output:&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Now : 2011-12-16 AT 03:57:40&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-8850999302894371094?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/i3idPQz2Npq_0gJ3RdcBImvTJWI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/i3idPQz2Npq_0gJ3RdcBImvTJWI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/i3idPQz2Npq_0gJ3RdcBImvTJWI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/i3idPQz2Npq_0gJ3RdcBImvTJWI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/769EcPryKqE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/8850999302894371094/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2011/12/javalangillegalargumentexception.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/8850999302894371094?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/8850999302894371094?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/769EcPryKqE/javalangillegalargumentexception.html" title="java.lang.IllegalArgumentException: Illegal pattern character 'AT'" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2011/12/javalangillegalargumentexception.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEEAQ3c6fCp7ImA9WhRXEE4.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-5632430450713812143</id><published>2011-12-15T20:17:00.003+05:30</published><updated>2011-12-16T16:20:42.914+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-16T16:20:42.914+05:30</app:edited><title>A repository hook failed</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;A repository hook failed&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;svn: Commit blocked by pre-commit hook (exit code 1) with output:&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Please enter a log message to commit&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
I got above error while commiting my changes into SVN repository. As the error suggest "Please enter a log message to commit". Make sure you enter a message for commiting. It expects a message to commit, make sure that the message box is not left blank.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-5632430450713812143?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/gJ0vkPtrsRKcCQDzhHfRSdJncQ0/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/gJ0vkPtrsRKcCQDzhHfRSdJncQ0/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/gJ0vkPtrsRKcCQDzhHfRSdJncQ0/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/gJ0vkPtrsRKcCQDzhHfRSdJncQ0/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/khvo1IPw9L4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/5632430450713812143/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2011/12/repository-hook-failed.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/5632430450713812143?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/5632430450713812143?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/khvo1IPw9L4/repository-hook-failed.html" title="A repository hook failed" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2011/12/repository-hook-failed.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkUHRXs7fyp7ImA9WhRQGUs.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-3354354343967716110</id><published>2011-12-15T20:13:00.002+05:30</published><updated>2011-12-15T20:13:54.507+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-15T20:13:54.507+05:30</app:edited><title>CLI0611E  Invalid column name. SQLSTATE=S0022</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;COM.ibm.db2.jdbc.DB2Exception: [IBM][JDBC Driver] CLI0611E&amp;nbsp; Invalid column name. SQLSTATE=S0022&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.rsException(Unknown Source)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at COM.ibm.db2.jdbc.app.DB2ResultSet.findColumn(Unknown Source)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at COM.ibm.db2.jdbc.app.DB2ResultSet.getString(Unknown Source)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As the get above error suggest, The column name specified in the Query or in resultSet is invalid.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;resultSet.getString("COLUMN_NAME");&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Please re-check all the column names against table name and make sure it is correct.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-3354354343967716110?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/o09Bo_LinaviON9i989ayBOcmBs/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/o09Bo_LinaviON9i989ayBOcmBs/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/o09Bo_LinaviON9i989ayBOcmBs/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/o09Bo_LinaviON9i989ayBOcmBs/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/Ps3Kp9HdFMY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/3354354343967716110/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2011/12/cli0611e-invalid-column-name.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/3354354343967716110?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/3354354343967716110?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/Ps3Kp9HdFMY/cli0611e-invalid-column-name.html" title="CLI0611E  Invalid column name. SQLSTATE=S0022" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2011/12/cli0611e-invalid-column-name.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0ABR3ozfSp7ImA9WhRQGUg.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-2024440645262769056</id><published>2011-12-15T20:05:00.000+05:30</published><updated>2011-12-15T20:05:56.485+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-15T20:05:56.485+05:30</app:edited><title>SQL1336N  The remote host "serverX" was not found</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Exception in thread "main" COM.ibm.db2.jdbc.DB2Exception: [IBM][CLI Driver] SQL1336N  The remote host "serverX" was not found.&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.throw_SQLException(Unknown Source)&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;at COM.ibm.db2.jdbc.app.SQLExceptionGenerator.check_return_code(Unknown Source)&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;at COM.ibm.db2.jdbc.app.DB2Connection.connect(Unknown Source)&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;at COM.ibm.db2.jdbc.app.DB2Connection.&lt;init&gt;(Unknown Source)&lt;br /&gt;
at COM.ibm.db2.jdbc.app.DB2Driver.connect(Unknown Source)&lt;br /&gt;
at java.sql.DriverManager.getConnection(DriverManager.java:582)&lt;br /&gt;
at java.sql.DriverManager.getConnection(DriverManager.java:185)&lt;/init&gt;&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="color: black; font-family: inherit;"&gt;&lt;init&gt;If you get above error, one possible reason could be the alias name used could be pointing to wrong database server.&lt;br /&gt;
&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: red;"&gt;Connection&lt;/span&gt; con=&lt;span style="color: red;"&gt;DriverManager&lt;/span&gt;.getConnection(&lt;span style="color: magenta;"&gt;"jdbc:db2:ALIASNAME"&lt;/span&gt;,&lt;span style="color: magenta;"&gt;"username"&lt;/span&gt;,&lt;span style="color: magenta;"&gt;"password"&lt;/span&gt;);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
In my case ALIASNAME was required to point serverX but it was referring to serverY. I knew the solution but I did not know how to do it. I asked my database administrator (DBA) to have a look at the issue. What he told me is, he has to uncatalog and catalog it with the correct server.&lt;br /&gt;
&lt;br /&gt;
Truly speaking I don’t know the meaning of these terms "&lt;b&gt;uncatalog and catalog&lt;/b&gt;", I asked him let me know the solution as this issue may arise in future too. He told as i am a programmer, i cannot do the task which a DBA can do... Is it really?&lt;br /&gt;
&lt;br /&gt;
So dear friends I may disappoint you and I apologize for that. But if this is the case with yours please contact with your database administrator.&lt;br /&gt;
&amp;nbsp;&lt;/init&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-2024440645262769056?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/c432sGfI-xLgvPXBG7z_uDP603o/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/c432sGfI-xLgvPXBG7z_uDP603o/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/c432sGfI-xLgvPXBG7z_uDP603o/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/c432sGfI-xLgvPXBG7z_uDP603o/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/M27bppWyxJ4" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/2024440645262769056/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2011/12/sql1336n-remote-host-serverx-was-not.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/2024440645262769056?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/2024440645262769056?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/M27bppWyxJ4/sql1336n-remote-host-serverx-was-not.html" title="SQL1336N  The remote host &quot;serverX&quot; was not found" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2011/12/sql1336n-remote-host-serverx-was-not.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkIGRns9fip7ImA9WhRQGUg.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-1584359911959773596</id><published>2011-12-15T19:45:00.000+05:30</published><updated>2011-12-15T19:45:27.566+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-15T19:45:27.566+05:30</app:edited><title>Java : Simple way to get UTC/GMT date-time</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;In Java when you create a new Date OR Calendar object, it is initialized to the current time but in the local timezone where the program is running. For example, for a program running in India, creates a TimeZone object based on Indian Standard Time.&lt;br /&gt;
&lt;br /&gt;
In your java carrier you may need to get an UTC time (Coordinated Universal Time) or GMT time (Greenwich Mean Time). For this java provides a simple class known as &lt;b&gt;TimeZone&lt;/b&gt;, which help us to get date/time from any geographical region accross the globe. All you need to do is pass correct time zone abbreviation.&lt;br /&gt;
&lt;br /&gt;
To know more about &lt;b&gt;TimeZone&lt;/b&gt;, &lt;b&gt;&lt;a hre="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/TimeZone.html" href="http://docs.oracle.com/javase/1.5.0/docs/api/java/util/TimeZone.html" target="_blank"&gt;see API&lt;/a&gt;&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
Below are the examples of few time zone abbreviations&lt;br /&gt;
&lt;br /&gt;
&lt;table border="1" width="80%"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;Abbr&lt;/th&gt;&lt;th&gt;Name&lt;/th&gt;&lt;th&gt;UTC offset&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;AKST&lt;/td&gt;&lt;td&gt;Alaska Standard Time&lt;/td&gt;&lt;td&gt;UTC−09&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;AST&lt;/td&gt;&lt;td&gt;Atlantic Standard Time&lt;/td&gt;&lt;td&gt;UTC−04&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;CET&lt;/td&gt;&lt;td&gt;Central European Time&lt;/td&gt;&lt;td&gt;UTC+01&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;CT&lt;/td&gt;&lt;td&gt;China Time&lt;/td&gt;&lt;td&gt;UTC+08&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;IST&lt;/td&gt;&lt;td&gt;Indian Standard Time&lt;/td&gt;&lt;td&gt;UTC+05:30&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SGT&lt;/td&gt;&lt;td&gt;Singapore Time&lt;/td&gt;&lt;td&gt;UTC+08&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;UTC&lt;/td&gt;&lt;td&gt;Coordinated Universal Time&lt;/td&gt;&lt;td&gt;UTC&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;br /&gt;
Get list of all time zone abbreviations, &lt;a href="http://en.wikipedia.org/wiki/List_of_time_zone_abbreviations" target="_blank"&gt;click here&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #38761d; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;/* UTCDates.java */&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;import &lt;/span&gt;java.text.&lt;span style="color: red;"&gt;SimpleDateFormat&lt;/span&gt;;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;import &lt;/span&gt;java.util.&lt;span style="color: red;"&gt;Calendar&lt;/span&gt;;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;import &lt;/span&gt;java.util.&lt;span style="color: red;"&gt;TimeZone&lt;/span&gt;;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;public class &lt;/span&gt;UTCDates {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public static void&lt;/span&gt; main(&lt;span style="color: red;"&gt;String&lt;/span&gt;[] args) {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;Calendar &lt;/span&gt;cal = &lt;span style="color: red;"&gt;Calendar&lt;/span&gt;.getInstance();&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;SimpleDateFormat &lt;/span&gt;sdFormat =&amp;nbsp; &lt;span style="color: blue;"&gt;new &lt;/span&gt;&lt;span style="color: red;"&gt;SimpleDateFormat&lt;/span&gt;(&lt;span style="color: magenta;"&gt;"yyyy-MM-dd'T'hh:mm:ss"&lt;/span&gt;);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;String &lt;/span&gt;strDate;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; sdFormat.setTimeZone(&lt;span style="color: red;"&gt;TimeZone&lt;/span&gt;.getDefault());&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; strDate = sdFormat.format(cal.getTime());&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;System&lt;/span&gt;.out.println(&lt;span style="color: magenta;"&gt;"Now : "&lt;/span&gt;+strDate);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; sdFormat.setTimeZone(&lt;span style="color: red;"&gt;TimeZone&lt;/span&gt;.getTimeZone(&lt;span style="color: magenta;"&gt;"UTC"&lt;/span&gt;));&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; strDate = sdFormat.format(cal.getTime());&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;System&lt;/span&gt;.out.println(&lt;span style="color: magenta;"&gt;"UTC : "&lt;/span&gt;+strDate);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;}&lt;/span&gt; &lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Now : 2011-12-15T05:25:22&lt;/div&gt;&lt;div style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;UTC : 2011-12-15T11:55:22&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
Also Apache provides us an API to do this. To know more about it, &lt;b&gt;&lt;a href="http://commons.apache.org/lang/" target="_blank"&gt;click here&lt;/a&gt;&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
You need to download &lt;b&gt;commons-lang-x.x.jar&lt;/b&gt; and set it in classpath for example commons-lang-2.1.jar file.&lt;br /&gt;
To download commons-lang-x.x.jar, &lt;b&gt;&lt;a href="http://commons.apache.org/lang/download_lang.cgi" target="_blank"&gt;click here&lt;/a&gt;&lt;/b&gt;.&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style="color: #38761d; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;/* UTCDates.java */&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: red;"&gt;import &lt;/span&gt;java.util.Calendar;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: red;"&gt;import &lt;/span&gt;org.apache.commons.lang.time.DateFormatUtils;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;public class&lt;/span&gt; UTCDates {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public static void&lt;/span&gt; main(&lt;span style="color: red;"&gt;String&lt;/span&gt;[] args) {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;Calendar &lt;/span&gt;cal = &lt;span style="color: red;"&gt;Calendar&lt;/span&gt;.getInstance();&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;String &lt;/span&gt;strDate;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; strDate = DateFormatUtils.ISO_DATETIME_FORMAT.format(cal.getTime());&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;System&lt;/span&gt;.out.println(&lt;span style="color: magenta;"&gt;"Now : "&lt;/span&gt;+strDate);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; strDate = DateFormatUtils.formatUTC(cal.getTime(), DateFormatUtils.ISO_DATETIME_FORMAT.getPattern());&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;System&lt;/span&gt;.out.println(&lt;span style="color: magenta;"&gt;"UTC : "&lt;/span&gt;+strDate);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;More formats&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;table border="1" width="80%"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;th&gt;FastDateFormat&lt;/th&gt;&lt;th&gt;Pattern&lt;/th&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;ISO_DATETIME_FORMAT&lt;/td&gt;&lt;td&gt;yyyy-MM-dd'T'HH:mm:ss&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;ISO_DATETIME_TIME_ZONE_FORMAT&lt;/td&gt;&lt;td&gt;yyyy-MM-dd'T'HH:mm:ssZZ&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;ISO_DATE_FORMAT&lt;/td&gt;&lt;td&gt;yyyy-MM-dd&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;ISO_DATE_TIME_ZONE_FORMAT&lt;/td&gt;&lt;td&gt;yyyy-MM-ddZZ&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;ISO_TIME_FORMAT&lt;/td&gt;&lt;td&gt;'T'HH:mm:ss&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;ISO_TIME_TIME_ZONE_FORMAT&lt;/td&gt;&lt;td&gt;'T'HH:mm:ssZZ&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;ISO_TIME_NO_T_FORMAT&lt;/td&gt;&lt;td&gt;HH:mm:ss&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;ISO_TIME_NO_T_TIME_ZONE_FORMAT&lt;/td&gt;&lt;td&gt;HH:mm:ssZZ&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td&gt;SMTP_DATETIME_FORMAT&lt;/td&gt;&lt;td&gt;EEE, dd MMM yyyy HH:mm:ss Z&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-1584359911959773596?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Q_oyKkZk8FIITnTzXsVut_0O9mk/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Q_oyKkZk8FIITnTzXsVut_0O9mk/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Q_oyKkZk8FIITnTzXsVut_0O9mk/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Q_oyKkZk8FIITnTzXsVut_0O9mk/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/l-zAuIL4GBg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/1584359911959773596/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2011/12/java-simple-way-to-get-utcgmt-date-time.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/1584359911959773596?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/1584359911959773596?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/l-zAuIL4GBg/java-simple-way-to-get-utcgmt-date-time.html" title="Java : Simple way to get UTC/GMT date-time" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2011/12/java-simple-way-to-get-utcgmt-date-time.html</feedburner:origLink></entry><entry gd:etag="W/&quot;C0EAR3g6eyp7ImA9WhRQFEw.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-5270718760302980326</id><published>2011-12-09T11:50:00.000+05:30</published><updated>2011-12-09T11:50:46.613+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-09T11:50:46.613+05:30</app:edited><title>SQL0206N, SQL0180N &amp; SQL0408N</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;I observed below mentioned error while working with DB2 query.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Error :&lt;/b&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;S0022(-206)[IBM][CLI Driver][DB2/SUN64] SQL0206N&amp;nbsp; "2" is not valid in the context where it is used.&amp;nbsp; SQLSTATE=42703&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;(0.58 secs)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Solution :&lt;/b&gt;&lt;br /&gt;
This error occurs when u try to compare OR assign values of different datatypes. For example COUNT = '2' will throw above error because COUNT is INT and you are trying to assing STRING to it. To avoid above error make sure datatypes are correct.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Error :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; 22007(-180)[IBM][CLI Driver][DB2/SUN64] SQL0180N&amp;nbsp; The syntax of the string representation of a datetime value is incorrect.&amp;nbsp; SQLSTATE=22007&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;(0.73 secs)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Solution :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
This error occurs when working with DATETIME datatypes. Usually when assigning or comparing STRING to a DATETIME value.&lt;br /&gt;
&lt;br /&gt;
If you need to compare / assign a STRING to DATETIME use below syntax.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;DATETIME_VARIABLE = TIMESTAMP ('2011-12-08-15.49.26.000625')&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Error :&lt;/b&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp; 22005(-408)[IBM][CLI Driver][DB2/SUN64] SQL0408N&amp;nbsp; A value is not compatible with the data type of its assignment target.&amp;nbsp; Target name is "DATETIME_VARIABLE".&amp;nbsp; SQLSTATE=42821&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;(0.48 secs)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
To convert a character string to a date or time value, you can use:&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;TIMESTAMP ('2002-10-20 12:00:00') &lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;DATE ('2002-10-20') &lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;DATE ('10/20/2002') &lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;TIME ('12:00:00') &lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;TIME ('12.00.00') &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The TIMESTAMP(), DATE() and TIME() functions accept many other formats.&lt;br /&gt;
&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-5270718760302980326?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/szs7Exn2xmdCmphPYdLl42A28qE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/szs7Exn2xmdCmphPYdLl42A28qE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/szs7Exn2xmdCmphPYdLl42A28qE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/szs7Exn2xmdCmphPYdLl42A28qE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/_89UBRanFMw" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/5270718760302980326/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2011/12/sql0206n-sql0180n-sql0408n.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/5270718760302980326?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/5270718760302980326?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/_89UBRanFMw/sql0206n-sql0180n-sql0408n.html" title="SQL0206N, SQL0180N &amp; SQL0408N" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2011/12/sql0206n-sql0180n-sql0408n.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUMAQn46cSp7ImA9WhRQEks.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-8528982435177865799</id><published>2011-12-07T19:47:00.000+05:30</published><updated>2011-12-07T19:47:23.019+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-07T19:47:23.019+05:30</app:edited><title>java.io.FileNotFoundException: log4j.xml (No such file or directory)</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;If you get below mentioned error&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;log4j:ERROR Could not parse url [file:log4j.xml].&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java.io.FileNotFoundException: log4j.xml (No such file or directory)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.io.FileInputStream.open(Native Method)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:106)&lt;/init&gt;&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at java.io.FileInputStream.&lt;init&gt;(FileInputStream.java:66)&lt;/init&gt;&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at sun.net.www.protocol.file.FileURLConnection.connect(FileURLConnection.java:70)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at sun.net.www.protocol.file.FileURLConnection.getInputStream(FileURLConnection.java:161)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.xerces.impl.XMLEntityManager.setupCurrentEntity(Unknown Source)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.xerces.impl.XMLVersionDetector.determineDocVersion(Unknown Source)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.xerces.parsers.XML11Configuration.parse(Unknown Source)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.xerces.parsers.XMLParser.parse(Unknown Source)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:180)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.log4j.xml.DOMConfigurator$2.parse(DOMConfigurator.java:612)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:711)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.log4j.xml.DOMConfigurator.doConfigure(DOMConfigurator.java:618)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.log4j.helpers.OptionConverter.selectAndConfigure(OptionConverter.java:470)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.log4j.LogManager.&lt;clinit&gt;(LogManager.java:122)&lt;/clinit&gt;&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.slf4j.impl.Log4jLoggerFactory.getLogger(Log4jLoggerFactory.java:73)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:242)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.slf4j.LoggerFactory.getLogger(LoggerFactory.java:254)&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.quartz.impl.StdSchedulerFactory.&lt;init&gt;(StdSchedulerFactory.java:274)&lt;/init&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Possible reason could be JVM is not able to find the provided file log4j.xml. Make sure the file is present in the location and You could pass the file in command line as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;java -Dlog4j.configuration=file:/home/log4j.xml com.TestJava&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;OR&lt;/b&gt; add directly in your Java code.&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;System.setProperty("log4j.configuration", "/home/log4j.xml");&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
If you are using Eclipe IDE you can pass through VM arguments by steps shown below&lt;br /&gt;
&lt;br /&gt;
Right click on Java -&amp;gt; Run As -&amp;gt; Run Configurations.. -&amp;gt; Arguments tab -&amp;gt; VM arguments&lt;br /&gt;
&lt;br /&gt;
add the below code&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;-Dlog4j.configuration=file:/home/log4j.xml&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Apply -&amp;gt; Run&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-8528982435177865799?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/hLrmluNNSNvVKP2a7DDRulyvB0A/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hLrmluNNSNvVKP2a7DDRulyvB0A/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/hLrmluNNSNvVKP2a7DDRulyvB0A/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/hLrmluNNSNvVKP2a7DDRulyvB0A/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/26ciuiSaMgQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/8528982435177865799/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2011/12/javaiofilenotfoundexception-log4jxml-no.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/8528982435177865799?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/8528982435177865799?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/26ciuiSaMgQ/javaiofilenotfoundexception-log4jxml-no.html" title="java.io.FileNotFoundException: log4j.xml (No such file or directory)" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2011/12/javaiofilenotfoundexception-log4jxml-no.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEYMR34_eCp7ImA9WhRQEks.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-2277284881137280074</id><published>2011-12-07T19:26:00.002+05:30</published><updated>2011-12-07T19:26:26.040+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-07T19:26:26.040+05:30</app:edited><title>SQLSTATE=42501</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;If you get below mentioned error for DB2&lt;br /&gt;
&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;42501(-551)[IBM][CLI Driver][DB2/SUN64] SQL0551N&amp;nbsp; "USER" does not have the privilege to perform operation "SELECT" on object "SCHEMA.TABLE_NAME".&amp;nbsp; SQLSTATE=42501 (0.48 secs)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As the error suggest your SQL administrator has not given privilege to perform SELECT operation on the particular table / View. Contact your SQL administrator and ask to grant privilege to perform operations on the table.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-2277284881137280074?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/Ruq3Si17RQbzMG-uykhsEvaRXGE/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ruq3Si17RQbzMG-uykhsEvaRXGE/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/Ruq3Si17RQbzMG-uykhsEvaRXGE/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/Ruq3Si17RQbzMG-uykhsEvaRXGE/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/36TZDfL688Q" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/2277284881137280074/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2011/12/sqlstate42501.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/2277284881137280074?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/2277284881137280074?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/36TZDfL688Q/sqlstate42501.html" title="SQLSTATE=42501" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2011/12/sqlstate42501.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEYBQXg5fip7ImA9WhRQEks.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-8069369219950867487</id><published>2011-12-07T19:25:00.002+05:30</published><updated>2011-12-07T19:25:50.626+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-07T19:25:50.626+05:30</app:edited><title>Invalid SQL syntax. SQLSTATE=37000</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;If you get below mentioned error for DB2&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;37000(-99999)[IBM][CLI Driver] CLI0118E&amp;nbsp; Invalid SQL syntax. SQLSTATE=37000 (0.03 secs)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As the error suggest, There could be a syntax error in the SQL. Please make sure that all the syntax for the SQL query is correct. Cross check for the syntax error.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-8069369219950867487?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/TH6MTPrOolDieoWlySN7B--J7YI/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/TH6MTPrOolDieoWlySN7B--J7YI/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/TH6MTPrOolDieoWlySN7B--J7YI/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/TH6MTPrOolDieoWlySN7B--J7YI/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/H9I7GKXj644" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/8069369219950867487/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2011/12/invalid-sql-syntax-sqlstate37000.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/8069369219950867487?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/8069369219950867487?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/H9I7GKXj644/invalid-sql-syntax-sqlstate37000.html" title="Invalid SQL syntax. SQLSTATE=37000" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2011/12/invalid-sql-syntax-sqlstate37000.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CE8NQ3c4eCp7ImA9WhRQEks.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-3848891998732177075</id><published>2011-12-07T18:31:00.000+05:30</published><updated>2011-12-07T18:31:32.930+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-07T18:31:32.930+05:30</app:edited><title>Unresolved compilation problem</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Exception in thread "main" java.lang.Error: Unresolved compilation problem: &lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Unhandled exception type Exception&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
A java file cannot be ran unless and until it is compilation error free. JVM compiler understands any syntax error or compile time error before it could create runable byte code (.class file). Hence JVM can run a java program only after successful compilation. Look for the compile time error if you get above error.&lt;br /&gt;
&lt;br /&gt;
JVM will run the code no matter if there is any run time exception. If there is any run time exception that will handled at run time accordingly. You must ensure that atleast a code do not contains any syntax error and is compileable.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How to solve compile error?&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Solving compilation error is very simple, all you need to do is follow all rules and regulation of JVM. To solve compilation error you need to check for Syntax error, Scope of a variable, Non reachable statements, Exceptions handling etc&lt;br /&gt;
&lt;br /&gt;
Solving compilation error is simple because it can be viewed. A simple Google search can solve your compilation error. Also IDEs like Eclipse, NetBeans etc has advance features which can show any compile error while wring the code itself i.e. before even compilation.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;How to solve run time error/exceptions?&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
My personal experience says solving a RUN time error could me very tough in some cases. You may even require to spend overnight to solve a simple run time exceptions because it cannot be viewed by compiler. In most cases there is a data issue. Run time exception could be simply a null pointer exception which occurs because the object is null.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Example : &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Code &lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;System.out.println(tempStr.trim());&lt;/span&gt;&lt;br /&gt;
Can throw&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Exception in thread "main" java.lang.NullPointerException&lt;/span&gt;&lt;br /&gt;
because tempStr is &lt;b&gt;null&lt;/b&gt;.&lt;br /&gt;
&lt;br /&gt;
The answer to the above question is debugging i.e. try to debug your code. Put logs wherever you doubt for the values. In the above example if you print the value of tempStr you will recognize the root cause of the exception. Also try to put exception handling codes i.e.&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt; try { .. } catch (Exception ex) {..}&lt;/span&gt; wherever you doubt for the values.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-3848891998732177075?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/zTqu-wlPqcQ2F--i6vXn118jvRM/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zTqu-wlPqcQ2F--i6vXn118jvRM/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/zTqu-wlPqcQ2F--i6vXn118jvRM/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/zTqu-wlPqcQ2F--i6vXn118jvRM/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/yvXx_QV3F-E" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/3848891998732177075/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2011/12/unresolved-compilation-problem.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/3848891998732177075?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/3848891998732177075?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/yvXx_QV3F-E/unresolved-compilation-problem.html" title="Unresolved compilation problem" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2011/12/unresolved-compilation-problem.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A04EQn4_eSp7ImA9WhRQEkg.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-2053466694377657241</id><published>2011-12-07T17:41:00.000+05:30</published><updated>2011-12-07T17:41:43.041+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-07T17:41:43.041+05:30</app:edited><title>Source File Declaration Rules in Java</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;C:\folder&amp;gt;javac test.java&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;test.java:9: class Test is public, should be declared in a file named Test.java&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;public class test&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ^&lt;/span&gt;&lt;br style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;1 error&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The above error appeared because the source file declaration rules in java says that If there is a public class in a file, the name of the file must match the name of the public class. For example, a class declared as public class Test { } must be in a source code file named Test.java. Also note that in Java everything is case-sensitive hence test and Test are treated as two different things.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Below are the rules associated with declaring classes, import statements, and package statements in a source file.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;&lt;li&gt;There can be only one public class per source code file.&lt;/li&gt;
&lt;li&gt;Comments can appear at the beginning or end of any line in the source code file; they are independent of any of the positioning rules discussed here.&lt;/li&gt;
&lt;li&gt;If there is a public class in a file, the name of the file must match the name of the public class. For example, a class declared as public class Test { } must be in a source code file named Test.java.&lt;/li&gt;
&lt;li&gt;If the class is part of a package, the package statement must be the first line in the source code file, before any import statements that may be present.&lt;/li&gt;
&lt;li&gt;If there are import statements, they must go between the package statement (if there is one) and the class declaration. If there isn't a package statement, then the import statement(s) must be the first line(s) in the source code file. If there are no package or import statements, the class declaration must be the first line in the source code file.&lt;/li&gt;
&lt;li&gt;import and package statements apply to all classes within a source code file. In other words, there's no way to declare multiple classes in a file and have them in different packages, or use different imports.&lt;/li&gt;
&lt;li&gt;A file can have more than one nonpublic class.&lt;/li&gt;
&lt;li&gt;Files with no public classes can have a name that does not match any of the classes in the file&lt;/li&gt;
&lt;/ul&gt;&lt;div style="text-align: left;"&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-2053466694377657241?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/r5jiXIVvTuhC3yZo9D6ysifEeBY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/r5jiXIVvTuhC3yZo9D6ysifEeBY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/r5jiXIVvTuhC3yZo9D6ysifEeBY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/r5jiXIVvTuhC3yZo9D6ysifEeBY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/9lW3WFRvdFE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/2053466694377657241/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2011/12/source-file-declaration-rules-in-java.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/2053466694377657241?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/2053466694377657241?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/9lW3WFRvdFE/source-file-declaration-rules-in-java.html" title="Source File Declaration Rules in Java" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2011/12/source-file-declaration-rules-in-java.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUUHQHY-cCp7ImA9WhRQF0s.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-7074560807837510247</id><published>2011-12-07T17:17:00.003+05:30</published><updated>2011-12-13T13:30:31.858+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-13T13:30:31.858+05:30</app:edited><title>How to send mail using MAILX command in UNIX / LINUX</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;b&gt;Simple MAILX command&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Below is the syntax to send simple mail using mailx command in UNIX / Linux.&lt;br /&gt;
You can use it as command line or used it in your shell script.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$ mailx -s "Mail Subject" test@xyz.com&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;type body of the mail&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;...&lt;/span&gt;&lt;br /&gt;
&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;..&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;EOT (Ctrl+d)&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;$&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Send attachment using MAILX command&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
In some cases you may have to send attachment in the mail. Lets see the syntax of sending an attachment using mailx command.&lt;br /&gt;
&lt;br /&gt;
Below is the syntax to attach a file while sending a mail using mailx command in LINUX / UNIX&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;( &lt;/span&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;cat /root/MailBody.txt&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;uuencode /root/file_name.txt file_name.txt&amp;nbsp; &lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;) | mailx -s "Mail Subject" test@xyz.com&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
Here&lt;b&gt; file_name.txt&lt;/b&gt; is the attachment to be attached in the mail&lt;br /&gt;
AND &lt;b&gt;MailBody.txt &lt;/b&gt;is the text body of the mail.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-7074560807837510247?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/_uYdz_TzMUMZ8drP0vAbk-XDEHY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_uYdz_TzMUMZ8drP0vAbk-XDEHY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/_uYdz_TzMUMZ8drP0vAbk-XDEHY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/_uYdz_TzMUMZ8drP0vAbk-XDEHY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/SWdilBBXcC8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/7074560807837510247/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2011/12/how-to-send-mail-using-mailx-command-in.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/7074560807837510247?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/7074560807837510247?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/SWdilBBXcC8/how-to-send-mail-using-mailx-command-in.html" title="How to send mail using MAILX command in UNIX / LINUX" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2011/12/how-to-send-mail-using-mailx-command-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEcARnc8fCp7ImA9WhRQE0g.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-8333501237704389728</id><published>2011-12-07T16:26:00.001+05:30</published><updated>2011-12-08T19:17:27.974+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-08T19:17:27.974+05:30</app:edited><title>Simple Cryptography example in Java</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;The Java security APIs span a wide range of areas, including cryptography, public key infrastructure, secure communication, authentication, and access control. Java security technology provides the developer with a comprehensive security framework for writing applications, and also provides the user or administrator with a set of tools to securely manage applications.&lt;br /&gt;
&lt;b&gt;Source&lt;/b&gt; : &lt;a href="http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136007.html"&gt;http://www.oracle.com/technetwork/java/javase/tech/index-jsp-136007.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;javax.crypto.Cipher&lt;/b&gt;&lt;br /&gt;
This class provides the functionality of a cryptographic cipher for encryption and decryption. It forms the core of the Java Cryptographic Extension (JCE) framework. &lt;br /&gt;
&lt;b&gt;Cipher API&lt;/b&gt; : &lt;a href="http://docs.oracle.com/javase/6/docs/api/javax/crypto/Cipher.html"&gt;http://docs.oracle.com/javase/6/docs/api/javax/crypto/Cipher.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Cipher&lt;/b&gt;: initialized with keys, these used for encrypting/decrypting data. There are various types of algorithms: symmetric bulk encryption (e.g. AES, DES, DESede, Blowfish, IDEA)&lt;br /&gt;
&lt;a href="http://docs.oracle.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html"&gt;http://docs.oracle.com/javase/6/docs/technotes/guides/security/crypto/CryptoSpec.html&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Blowfish&amp;nbsp; &lt;/b&gt;&lt;br /&gt;
Blowfish has a 64-bit block size and a variable key length from 1 bit up to 448 bits&lt;br /&gt;
&lt;b&gt;Blowfish Wiki&lt;/b&gt; : &lt;a href="http://en.wikipedia.org/wiki/Blowfish_%28cipher%29"&gt;http://en.wikipedia.org/wiki/Blowfish_%28cipher%29&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
To run this example you will need below mentioned JAR files in classpath.&lt;br /&gt;
&lt;b&gt;jce.jar&lt;br /&gt;
rt.jar&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
However you dont have to download these JAR files, It is implicitly there within jre folder.&lt;br /&gt;
You can cross verify in JRE folder. Probably in "&lt;b&gt;C:\Program Files\Java\jre6\lib&lt;/b&gt;"&lt;br /&gt;
&lt;br /&gt;
Hence &lt;b&gt;C:\Program Files\Java\jre6\lib\jce.jar&lt;/b&gt; and &lt;b&gt;C:\Program Files\Java\jre6\lib\rt.jar &lt;/b&gt;are implicitly set in your classpath.&lt;br /&gt;
&lt;br /&gt;
Below is the sample self explanatory Java program using Blowfish Cipher. Directly you can run the program and see output.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Simple Blowfish Cipher Example in java&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: #38761d; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;/* SimpleCryptography.java */&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;import &lt;/span&gt;javax.crypto.&lt;span style="color: red;"&gt;Cipher&lt;/span&gt;;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;import &lt;/span&gt;javax.crypto.spec.&lt;span style="color: red;"&gt;SecretKeySpec&lt;/span&gt;;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;import &lt;/span&gt;sun.misc.BASE64Decoder;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;import &lt;/span&gt;sun.misc.BASE64Encoder;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: blue;"&gt;public class&lt;/span&gt; SimpleCryptography {&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: blue;"&gt;private &lt;/span&gt;&lt;span style="color: red;"&gt;String &lt;/span&gt;AlgoName = &lt;span style="color: magenta;"&gt;"Blowfish"&lt;/span&gt;;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;private &lt;/span&gt;&lt;span style="color: red;"&gt;String &lt;/span&gt;keyString = &lt;span style="color: magenta;"&gt;"DesireSecretKey"&lt;/span&gt;;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public &lt;/span&gt;&lt;span style="color: red;"&gt;String &lt;/span&gt;encrypt(&lt;span style="color: red;"&gt;String &lt;/span&gt;sValue) &lt;span style="color: blue;"&gt;throws &lt;/span&gt;&lt;span style="color: red;"&gt;Exception &lt;/span&gt;{&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: red;"&gt;SecretKeySpec &lt;/span&gt;skeySpec = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: red;"&gt;SecretKeySpec&lt;/span&gt;(keyString.getBytes(), AlgoName);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: red;"&gt;Cipher &lt;/span&gt;cipher = &lt;span style="color: red;"&gt;Cipher&lt;/span&gt;.getInstance(AlgoName);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;cipher.init(&lt;span style="color: red;"&gt;Cipher&lt;/span&gt;.ENCRYPT_MODE, skeySpec);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: blue;"&gt;byte&lt;/span&gt;[] encrypted = cipher.doFinal(sValue.getBytes());&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BASE64Encoder bASE64Encoder = &lt;span style="color: blue;"&gt;new &lt;/span&gt;BASE64Encoder();&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: red;"&gt;String &lt;/span&gt;enStr = bASE64Encoder.encodeBuffer(encrypted);&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: blue;"&gt;return &lt;/span&gt;enStr;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: blue;"&gt;public &lt;/span&gt;&lt;span style="color: red;"&gt;String &lt;/span&gt;decrypt(&lt;span style="color: red;"&gt;String &lt;/span&gt;sValue) &lt;span style="color: blue;"&gt;throws &lt;/span&gt;&lt;span style="color: red;"&gt;Exception &lt;/span&gt;{&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: red;"&gt;SecretKeySpec &lt;/span&gt;skeySpec = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: red;"&gt;SecretKeySpec&lt;/span&gt;(keyString.getBytes(), AlgoName);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: red;"&gt;Cipher &lt;/span&gt;cipher = &lt;span style="color: red;"&gt;Cipher&lt;/span&gt;.getInstance(AlgoName);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;BASE64Decoder bASE64Decoder = &lt;span style="color: blue;"&gt;new &lt;/span&gt;BASE64Decoder();&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;byte &lt;/span&gt;decrytByt[] = bASE64Decoder.decodeBuffer(sValue);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; cipher.init(&lt;span style="color: red;"&gt;Cipher&lt;/span&gt;.DECRYPT_MODE, skeySpec);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;byte &lt;/span&gt;decrypted[] = cipher.doFinal(decrytByt);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;String &lt;/span&gt;deStr = &lt;span style="color: blue;"&gt;new &lt;/span&gt;&lt;span style="color: red;"&gt;String&lt;/span&gt;(decrypted).trim();&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: blue;"&gt;return &lt;/span&gt;deStr;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: blue;"&gt;public static void&lt;/span&gt; main(&lt;span style="color: red;"&gt;String&lt;/span&gt;[] args) &lt;span style="color: blue;"&gt;throws &lt;/span&gt;&lt;span style="color: red;"&gt;Exception &lt;/span&gt;{&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;SimpleCryptography obj = new SimpleCryptography();&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: red;"&gt;String &lt;/span&gt;password = &lt;span style="color: magenta;"&gt;"MadanChaudhary"&lt;/span&gt;;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: red;"&gt;System&lt;/span&gt;.out.println(&lt;span style="color: magenta;"&gt;"password : "&lt;/span&gt;+password);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: red;"&gt;String &lt;/span&gt;encrypted_password = obj.encrypt(password);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: red;"&gt;System&lt;/span&gt;.out.println(&lt;span style="color: magenta;"&gt;"encrypted_password : "&lt;/span&gt;+encrypted_password);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: red;"&gt;String &lt;/span&gt;decrypted_password = obj.decrypt(encrypted_password);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;span style="color: red;"&gt;System&lt;/span&gt;.out.println(&lt;span style="color: magenta;"&gt;"decrypted_password : "&lt;/span&gt;+decrypted_password);&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;" /&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b style="font-family: inherit;"&gt;Output : &lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;password : MadanChaudhary&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;encrypted_password : 0LpwIuI0V+44sbZ5w3CCZw==&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;decrypted_password : MadanChaudhary&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Below are the known Errors and exceptions I observed while writing this program.&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;1.&lt;/b&gt;&lt;br /&gt;
javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at com.sun.crypto.provider.BlowfishCipher.engineDoFinal(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.doFinal(DashoA13*..)&lt;br /&gt;
Exception in thread "main" javax.crypto.IllegalBlockSizeException: Input length must be multiple of 8 when decrypting with padded cipher&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at com.sun.crypto.provider.BlowfishCipher.engineDoFinal(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.doFinal(DashoA13*..)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;2.&lt;/b&gt;&lt;br /&gt;
java.security.InvalidKeyException: Illegal key size or default parameters&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.a(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.a(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.a(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.init(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.init(DashoA13*..)&lt;br /&gt;
Exception in thread "main" java.security.InvalidKeyException: Illegal key size or default parameters&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.a(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.a(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.a(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.init(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.init(DashoA13*..)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;3.&lt;/b&gt;&lt;br /&gt;
java.security.NoSuchAlgorithmException: Cannot find any provider supporting MyAlgo&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.getInstance(DashoA13*..)&lt;br /&gt;
Exception in thread "main" java.security.NoSuchAlgorithmException: Cannot find any provider supporting MyAlgo&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.getInstance(DashoA13*..)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;4.&lt;/b&gt;&lt;br /&gt;
java.security.InvalidKeyException: Invalid key length: 16 bytes&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at com.sun.crypto.provider.DESCipher.engineGetKeySize(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.b(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.a(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.a(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.a(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.init(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.init(DashoA13*..)&lt;br /&gt;
Exception in thread "main" java.security.InvalidKeyException: Invalid key length: 16 bytes&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at com.sun.crypto.provider.DESCipher.engineGetKeySize(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.b(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.a(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.a(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.a(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.init(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.init(DashoA13*..)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;5.&lt;/b&gt;&lt;br /&gt;
java.security.NoSuchAlgorithmException: Cannot find any provider supporting DSA&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.getInstance(DashoA13*..)&lt;br /&gt;
Exception in thread "main" java.security.NoSuchAlgorithmException: Cannot find any provider supporting DSA&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.getInstance(DashoA13*..)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;6.&lt;/b&gt;&lt;br /&gt;
javax.crypto.BadPaddingException: Given final block not properly padded&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at com.sun.crypto.provider.BlowfishCipher.engineDoFinal(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.doFinal(DashoA13*..)&lt;br /&gt;
Exception in thread "main" javax.crypto.BadPaddingException: Given final block not properly padded&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at com.sun.crypto.provider.SunJCE_f.b(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at com.sun.crypto.provider.BlowfishCipher.engineDoFinal(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.doFinal(DashoA13*..)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;7.&lt;/b&gt;&lt;br /&gt;
java.lang.IllegalStateException: Cipher not initialized&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.c(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.doFinal(DashoA13*..)&lt;br /&gt;
Exception in thread "main" java.lang.IllegalStateException: Cipher not initialized&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.c(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.doFinal(DashoA13*..)&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;8.&lt;/b&gt;&lt;br /&gt;
Exception in thread "main" java.security.InvalidKeyException: Illegal key size or default parameters&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.a(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.a(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.a(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.init(DashoA13*..)&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.crypto.Cipher.init(DashoA13*..)&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;9. Warnings&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
$javac SimpleCryptography.java&lt;br /&gt;
&lt;br /&gt;
SimpleCryptography.java:6: warning: sun.misc.BASE64Decoder is Sun proprietary API and may be removed in a future release&lt;br /&gt;
import sun.misc.BASE64Decoder;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ^&lt;br /&gt;
SimpleCryptography.java:7: warning: sun.misc.BASE64Encoder is Sun proprietary API and may be removed in a future release&lt;br /&gt;
import sun.misc.BASE64Encoder;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ^&lt;br /&gt;
SimpleCryptography.java:24: warning: sun.misc.BASE64Encoder is Sun proprietary API and may be removed in a future release&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BASE64Encoder bASE64Encoder = new BASE64Encoder();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ^&lt;br /&gt;
SimpleCryptography.java:24: warning: sun.misc.BASE64Encoder is Sun proprietary API and may be removed in a future release&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BASE64Encoder bASE64Encoder = new BASE64Encoder();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ^&lt;br /&gt;
SimpleCryptography.java:35: warning: sun.misc.BASE64Decoder is Sun proprietary API and may be removed in a future release&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BASE64Decoder bASE64Decoder = new BASE64Decoder();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ^&lt;br /&gt;
SimpleCryptography.java:35: warning: sun.misc.BASE64Decoder is Sun proprietary API and may be removed in a future release&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; BASE64Decoder bASE64Decoder = new BASE64Decoder();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; ^&lt;br /&gt;
6 warnings&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-8333501237704389728?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/3ZAakySNJIElCDqr_8zXxHtd1kw/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3ZAakySNJIElCDqr_8zXxHtd1kw/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/3ZAakySNJIElCDqr_8zXxHtd1kw/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/3ZAakySNJIElCDqr_8zXxHtd1kw/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/6Vw9w_fIrbs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/8333501237704389728/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2011/12/simple-cryptography-example-in-java.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/8333501237704389728?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/8333501237704389728?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/6Vw9w_fIrbs/simple-cryptography-example-in-java.html" title="Simple Cryptography example in Java" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2011/12/simple-cryptography-example-in-java.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DE8BQno4fyp7ImA9WhRRGE4.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-4464858241345793881</id><published>2011-12-02T20:10:00.000+05:30</published><updated>2011-12-02T20:10:53.437+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-02T20:10:53.437+05:30</app:edited><title>A pseudo attribute name is expected.</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;If you get below mentioned error&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue;"&gt;[Fatal Error] :1:54: A pseudo attribute name is expected. &lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;span style="color: blue;"&gt;Exception in thread "main" org.xml.sax.SAXParseException: A pseudo attribute name is expected. &lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)&lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)&lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:124)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Possible reason could be the version and encoding information provided is not formatted correctly.&lt;br /&gt;
Please used the below syntax and try again.&lt;br /&gt;
&lt;br /&gt;
?&amp;gt;&lt;br /&gt;
&lt;br /&gt;
Note the &lt;b style="color: red;"&gt;?&lt;/b&gt; at the end, I have missed that and it gave above error.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-4464858241345793881?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/WovlGwJzZugsnIVJj6PoAzemlzA/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/WovlGwJzZugsnIVJj6PoAzemlzA/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/WovlGwJzZugsnIVJj6PoAzemlzA/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/WovlGwJzZugsnIVJj6PoAzemlzA/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/t6NjXha7vk0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/4464858241345793881/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2011/12/pseudo-attribute-name-is-expected.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/4464858241345793881?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/4464858241345793881?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/t6NjXha7vk0/pseudo-attribute-name-is-expected.html" title="A pseudo attribute name is expected." /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2011/12/pseudo-attribute-name-is-expected.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEINSXw_eyp7ImA9WhRRGE4.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-6304136160886933025</id><published>2011-12-02T20:06:00.000+05:30</published><updated>2011-12-02T20:06:38.243+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-02T20:06:38.243+05:30</app:edited><title>XML document structures must start and end within the same entity.</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;If you get below mentioned error&lt;br /&gt;
&lt;div style="color: blue;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;span style="color: blue;"&gt;[Fatal Error] :1:7717: XML document structures must start and end within the same entity.&lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;span style="color: blue;"&gt;Exception in thread "main" org.xml.sax.SAXParseException: XML document structures must start and end within the same entity.&lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)&lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)&lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:124)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
As the error suggest XML document is not formatted properly. Kindly go through the XML and look for any missing tags.&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-6304136160886933025?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/4gcbEbu2BCPqohh9FzLs4zJ_tuY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4gcbEbu2BCPqohh9FzLs4zJ_tuY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/4gcbEbu2BCPqohh9FzLs4zJ_tuY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/4gcbEbu2BCPqohh9FzLs4zJ_tuY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/Ll8YQHuRIkc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/6304136160886933025/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2011/12/xml-document-structures-must-start-and.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/6304136160886933025?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/6304136160886933025?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/Ll8YQHuRIkc/xml-document-structures-must-start-and.html" title="XML document structures must start and end within the same entity." /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2011/12/xml-document-structures-must-start-and.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUcBQXkyfip7ImA9WhRXEE4.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-2236269759913442946</id><published>2011-12-02T17:59:00.007+05:30</published><updated>2011-12-16T16:27:30.796+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-12-16T16:27:30.796+05:30</app:edited><title>Indenting XML Output in Java</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;Here is a simple JAVA program for Indenting / Formatting a long XML string. You can provide a XML as a string OR can provide XML from a file according to your requirement.&lt;br /&gt;
&lt;br /&gt;
Formatting an XML can be useful for reading or just simply pretty printing it.&lt;br /&gt;
&lt;br /&gt;
Here is a complete tested code you can directly run the program and see the output.&lt;br /&gt;
&lt;br /&gt;
&lt;div style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="font-size: small;"&gt;&lt;span style="color: #38761d;"&gt;/* IndentXML.java */&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue;"&gt;import &lt;/span&gt;java.io.&lt;span style="color: red;"&gt;ByteArrayInputStream&lt;/span&gt;;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import &lt;/span&gt;java.io.&lt;span style="color: red;"&gt;File&lt;/span&gt;;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import &lt;/span&gt;java.io.&lt;span style="color: red;"&gt;FileOutputStream&lt;/span&gt;;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import &lt;/span&gt;java.io.&lt;span style="color: red;"&gt;IOException&lt;/span&gt;;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import &lt;/span&gt;java.io.&lt;span style="color: red;"&gt;InputStream&lt;/span&gt;;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import &lt;/span&gt;java.io.&lt;span style="color: red;"&gt;OutputStream&lt;/span&gt;;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue;"&gt;import &lt;/span&gt;javax.xml.parsers.&lt;span style="color: red;"&gt;DocumentBuilder&lt;/span&gt;;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import &lt;/span&gt;javax.xml.parsers.&lt;span style="color: red;"&gt;DocumentBuilderFactory&lt;/span&gt;;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import &lt;/span&gt;javax.xml.parsers.&lt;span style="color: red;"&gt;ParserConfigurationException&lt;/span&gt;;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import &lt;/span&gt;javax.xml.transform.&lt;span style="color: red;"&gt;OutputKeys&lt;/span&gt;;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import &lt;/span&gt;javax.xml.transform.&lt;span style="color: red;"&gt;Transformer&lt;/span&gt;;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import &lt;/span&gt;javax.xml.transform.&lt;span style="color: red;"&gt;TransformerException&lt;/span&gt;;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import &lt;/span&gt;javax.xml.transform.&lt;span style="color: red;"&gt;TransformerFactory&lt;/span&gt;;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import &lt;/span&gt;javax.xml.transform.dom.&lt;span style="color: red;"&gt;DOMSource&lt;/span&gt;;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import &lt;/span&gt;javax.xml.transform.stream.&lt;span style="color: red;"&gt;StreamResult&lt;/span&gt;;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue;"&gt;import &lt;/span&gt;org.w3c.dom.&lt;span style="color: red;"&gt;Document&lt;/span&gt;;&lt;br /&gt;
&lt;span style="color: blue;"&gt;import &lt;/span&gt;org.xml.sax.&lt;span style="color: red;"&gt;SAXException&lt;/span&gt;;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue;"&gt;public class&lt;/span&gt; IndentXML {&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: blue;"&gt;public static void&lt;/span&gt; main(&lt;span style="color: red;"&gt;String&lt;/span&gt;[] args) &lt;span style="color: blue;"&gt;throws &lt;/span&gt;&lt;span style="color: red;"&gt;ParserConfigurationException, SAXException, IOException, TransformerException &lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #38761d;"&gt;//get the factory&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;DocumentBuilderFactory &lt;/span&gt;dbf = &lt;span style="color: red;"&gt;DocumentBuilderFactory&lt;/span&gt;.newInstance();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #38761d;"&gt;//Using factory get an instance of document builder&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;DocumentBuilder &lt;/span&gt;db = dbf.newDocumentBuilder();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #38761d;"&gt;//providing XML string to be indented&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;/span&gt;&lt;span style="color: red;"&gt;String &lt;/span&gt;xmlStringToIndent = &lt;span style="color: magenta;"&gt;"&amp;lt;AllEmployee&amp;gt;&amp;lt;Employee&amp;gt;&amp;lt;Name&amp;gt;Ram&amp;lt;/Name&amp;gt;&amp;lt;Designation&amp;gt;Programmer&amp;lt;/Designation&amp;gt;&amp;lt;Department&amp;gt;Development&amp;lt;/Department&amp;gt;&amp;lt;/Employee&amp;gt;&amp;lt;Employee&amp;gt;&amp;lt;Name&amp;gt;Shyam&amp;lt;/Name&amp;gt;&amp;lt;Designation&amp;gt;TL&amp;lt;/Designation&amp;gt;&amp;lt;Department&amp;gt;Finanace&amp;lt;/Department&amp;gt;&amp;lt;/Employee&amp;gt;&amp;lt;Employee&amp;gt;&amp;lt;Name&amp;gt;Geeta&amp;lt;/Name&amp;gt;&amp;lt;Designation&amp;gt;Manager&amp;lt;/Designation&amp;gt;&amp;lt;Department&amp;gt;HR&amp;lt;/Department&amp;gt;&amp;lt;/Employee&amp;gt;&amp;lt;/AllEmployee&amp;gt;"&lt;/span&gt;;&lt;span style="font-size: small;"&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #38761d;"&gt;//converting String to InputStream&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;InputStream &lt;/span&gt;inStr = &lt;span style="color: blue;"&gt;new&lt;/span&gt; &lt;span style="color: red;"&gt;ByteArrayInputStream&lt;/span&gt;(xmlStringToIndent.getBytes());&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;Document &lt;/span&gt;doc = db.parse(inStr);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #38761d;"&gt;//Output file&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;File &lt;/span&gt;outputFile = &lt;span style="color: blue;"&gt;new &lt;/span&gt;&lt;span style="color: red;"&gt;File&lt;/span&gt;(&lt;span style="color: magenta;"&gt;"c:/indentedOutputXmlFile.xml"&lt;/span&gt;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;OutputStream &lt;/span&gt;outSrc = &lt;span style="color: blue;"&gt;new &lt;/span&gt;&lt;span style="color: red;"&gt;FileOutputStream&lt;/span&gt;(outputFile);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: #38761d;"&gt;//creating a transformer&lt;/span&gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;TransformerFactory &lt;/span&gt;transFactory = &lt;span style="color: red;"&gt;TransformerFactory&lt;/span&gt;.newInstance();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;Transformer &lt;/span&gt;transformer&amp;nbsp; = transFactory.newTransformer();&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; transformer.setOutputProperty(&lt;span style="color: red;"&gt;OutputKeys&lt;/span&gt;.ENCODING, &lt;span style="color: magenta;"&gt;"utf-8"&lt;/span&gt;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; transformer.setOutputProperty(&lt;span style="color: red;"&gt;OutputKeys&lt;/span&gt;.OMIT_XML_DECLARATION, &lt;span style="color: magenta;"&gt;"no"&lt;/span&gt;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; transformer.setOutputProperty(&lt;span style="color: red;"&gt;OutputKeys&lt;/span&gt;.INDENT, &lt;span style="color: magenta;"&gt;"yes"&lt;/span&gt;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; transformer.setOutputProperty(&lt;span style="color: magenta;"&gt;"{http://xml.apache.org/xslt}indent-amount"&lt;/span&gt;, &lt;span style="color: magenta;"&gt;"5"&lt;/span&gt;);&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; transformer.transform(new &lt;span style="color: red;"&gt;DOMSource&lt;/span&gt;(doc), &lt;span style="color: blue;"&gt;new &lt;/span&gt;&lt;span style="color: red;"&gt;StreamResult&lt;/span&gt;(outSrc));&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;span style="color: red;"&gt;System&lt;/span&gt;.out.println(&lt;span style="color: magenta;"&gt;"OutputFile created sucessfully!! "&lt;/span&gt;+outputFile.getPath());&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;br /&gt;
&lt;br /&gt;
}&lt;/span&gt;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="font-family: inherit; font-size: small;"&gt;&lt;b&gt;Input XML&lt;/b&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div style="color: black; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&lt;span style="color: red;"&gt;String &lt;/span&gt;xmlStringToIndent = &lt;span style="color: magenta;"&gt;"&amp;lt;AllEmployee&amp;gt;&amp;lt;Employee&amp;gt;&amp;lt;Name&amp;gt;Ram&amp;lt;/Name&amp;gt;&amp;lt;Designation&amp;gt;Programmer&amp;lt;/Designation&amp;gt;&amp;lt;Department&amp;gt;Development&amp;lt;/Department&amp;gt;&amp;lt;/Employee&amp;gt;&amp;lt;Employee&amp;gt;&amp;lt;Name&amp;gt;Shyam&amp;lt;/Name&amp;gt;&amp;lt;Designation&amp;gt;TL&amp;lt;/Designation&amp;gt;&amp;lt;Department&amp;gt;Finanace&amp;lt;/Department&amp;gt;&amp;lt;/Employee&amp;gt;&amp;lt;Employee&amp;gt;&amp;lt;Name&amp;gt;Geeta&amp;lt;/Name&amp;gt;&amp;lt;Designation&amp;gt;Manager&amp;lt;/Designation&amp;gt;&amp;lt;Department&amp;gt;HR&amp;lt;/Department&amp;gt;&amp;lt;/Employee&amp;gt;&amp;lt;/AllEmployee&amp;gt;"&lt;/span&gt;;&lt;/div&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Output XML&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;lt;?xml version="1.0" encoding="utf-8" standalone="no"?&amp;gt;&lt;br /&gt;
&amp;lt;AllEmployee&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Employee&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Name&amp;gt;Ram&amp;lt;/Name&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Designation&amp;gt;Programmer&amp;lt;/Designation&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Department&amp;gt;Development&amp;lt;/Department&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Employee&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Employee&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Name&amp;gt;Shyam&amp;lt;/Name&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Designation&amp;gt;TL&amp;lt;/Designation&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Department&amp;gt;Finanace&amp;lt;/Department&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Employee&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Employee&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Name&amp;gt;Geeta&amp;lt;/Name&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Designation&amp;gt;Manager&amp;lt;/Designation&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;Department&amp;gt;HR&amp;lt;/Department&amp;gt;&lt;br /&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;lt;/Employee&amp;gt;&lt;br /&gt;
&amp;lt;/AllEmployee&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style="color: black; font-family: inherit;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="color: black; font-family: inherit;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="color: black; font-family: inherit;"&gt;&lt;b&gt;&amp;nbsp;Note :&lt;/b&gt;&lt;/div&gt;&lt;div style="color: black; font-family: inherit;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="color: black; font-family: inherit;"&gt;If you are passing XML string and it contains double quotes ("). Make to to bypass it by adding backward slash (\").&lt;/div&gt;&lt;div style="color: black; font-family: inherit;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="color: black; font-family: inherit;"&gt;I observer below mentioned error when the string contained space in the beginning as show below. &lt;/div&gt;&lt;div style="color: black; font-family: inherit;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="color: black; font-family: inherit;"&gt;&lt;span style="color: red; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;String &lt;/span&gt;&lt;span style="font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;xmlStringToIndent = &lt;/span&gt;&lt;span style="color: magenta; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;" &amp;lt;AllEmployee&amp;gt;&amp;lt;Employee&amp;gt;&amp;lt;Name&amp;gt;Ram&amp;lt;/Name&amp;gt;&amp;lt;Designation&amp;gt;Programmer ....."&lt;/span&gt;&lt;/div&gt;&lt;div style="color: black; font-family: inherit;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="color: black; font-family: inherit;"&gt;Note the space in the beginning of the string. Make sure your XML is formatted properly.&lt;/div&gt;&lt;div style="color: black; font-family: inherit;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="color: black; font-family: inherit;"&gt;&lt;b&gt;Error&lt;/b&gt;&lt;/div&gt;&lt;div style="color: black; font-family: inherit;"&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div style="color: black; font-family: inherit;"&gt;&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;[Fatal Error] :1:7: The processing instruction target matching "[xX][mM][lL]" is not allowed.&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;Exception in thread "main" org.xml.sax.SAXParseException: The processing instruction target matching "[xX][mM][lL]" is not allowed.&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.xerces.parsers.DOMParser.parse(Unknown Source)&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at org.apache.xerces.jaxp.DocumentBuilderImpl.parse(Unknown Source)&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at javax.xml.parsers.DocumentBuilder.parse(DocumentBuilder.java:124)&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue; font-family: &amp;quot;Courier New&amp;quot;,Courier,monospace;"&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; at com.hewitt.hre.fadv.IndentXML.main(IndentXML.java:43)&lt;/span&gt;&lt;/div&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-2236269759913442946?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/B3mIkksnyHJ1wsXXBi_KkcFAFYU/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/B3mIkksnyHJ1wsXXBi_KkcFAFYU/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/B3mIkksnyHJ1wsXXBi_KkcFAFYU/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/B3mIkksnyHJ1wsXXBi_KkcFAFYU/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/Elm-GYwzPEY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/2236269759913442946/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2011/12/indenting-xml-output-in-java.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/2236269759913442946?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/2236269759913442946?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/Elm-GYwzPEY/indenting-xml-output-in-java.html" title="Indenting XML Output in Java" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2011/12/indenting-xml-output-in-java.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEMNSHgzfCp7ImA9WhRREk8.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-2418569467295184567</id><published>2011-11-25T18:37:00.001+05:30</published><updated>2011-11-25T18:38:19.684+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-25T18:38:19.684+05:30</app:edited><title>SQLSTATE=42903</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span style="color: blue;"&gt;&lt;span style="color: black;"&gt;&amp;nbsp;I was in need to pass a max value in where condition. My folly, what i did is :&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&lt;br style="color: black;" /&gt;&lt;span style="color: black;"&gt;&lt;b&gt;Incorrect :&lt;/b&gt; &lt;span style="color: purple;"&gt;Select * from table_name where field = MAX(field);&lt;/span&gt;&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&lt;span style="color: black;"&gt;Got below mentioned error in DB2&lt;/span&gt; &lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp; 42903(-120)[IBM][CLI Driver][DB2/SUN64] SQL0120N&amp;nbsp; Invalid use of an aggregate function or OLAP function.&amp;nbsp; SQLSTATE=42903&lt;/span&gt;&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp;(0.47 secs)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Correct :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Correct way is Inline Query&lt;br /&gt;
&lt;br /&gt;
&lt;b style="color: purple;"&gt;Select * from table_name where files = (Select MAX(filed) from table_name)&lt;/b&gt;&lt;span style="color: purple;"&gt;;&lt;/span&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-2418569467295184567?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/YPxLIj3v-c9r9wcGTR7ozyfz6sQ/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/YPxLIj3v-c9r9wcGTR7ozyfz6sQ/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/YPxLIj3v-c9r9wcGTR7ozyfz6sQ/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/YPxLIj3v-c9r9wcGTR7ozyfz6sQ/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/8C5-2EnoL-M" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/2418569467295184567/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2011/11/was-in-need-to-pass-max-value-in-where.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/2418569467295184567?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/2418569467295184567?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/8C5-2EnoL-M/was-in-need-to-pass-max-value-in-where.html" title="SQLSTATE=42903" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2011/11/was-in-need-to-pass-max-value-in-where.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEYDQXY4fyp7ImA9WhRREk8.&quot;"><id>tag:blogger.com,1999:blog-8882377031456587900.post-3348237380686917396</id><published>2011-11-25T18:32:00.000+05:30</published><updated>2011-11-25T18:32:50.837+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2011-11-25T18:32:50.837+05:30</app:edited><title>SQLSTATE=42601</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;&lt;span style="color: black;"&gt;I was in need to fetch top n rows from a particular table in DB2. I got below mentioned error when tried with some incorrect syntax.&lt;/span&gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;span style="color: blue;"&gt;&amp;nbsp;42601(-104)[IBM][CLI Driver][DB2/SUN64] SQL0104N&amp;nbsp; An unexpected token "1" was found following "Select TOP ".&amp;nbsp; Expected tokens may include:&amp;nbsp; "&lt;space&gt;".&amp;nbsp; SQLSTATE=42601&lt;/space&gt;&lt;/span&gt;&lt;br style="color: blue;" /&gt;&lt;span style="color: blue;"&gt;&amp;nbsp;(0.45 secs)&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Correct Syntax :&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
Select * from table_name where filed = 'Some condition' order by field &lt;b&gt;FETCH FIRST 10 ROWS ONLY;&lt;/b&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/8882377031456587900-3348237380686917396?l=www.simpleandeasycodes.com' alt='' /&gt;&lt;/div&gt;
&lt;p&gt;&lt;a href="http://feedads.g.doubleclick.net/~a/RFd9ssLAjedrUR2AfQWIHaC5SjY/0/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/RFd9ssLAjedrUR2AfQWIHaC5SjY/0/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;br/&gt;
&lt;a href="http://feedads.g.doubleclick.net/~a/RFd9ssLAjedrUR2AfQWIHaC5SjY/1/da"&gt;&lt;img src="http://feedads.g.doubleclick.net/~a/RFd9ssLAjedrUR2AfQWIHaC5SjY/1/di" border="0" ismap="true"&gt;&lt;/img&gt;&lt;/a&gt;&lt;/p&gt;&lt;img src="http://feeds.feedburner.com/~r/SimpleAndEasyCodes/~4/QIyzlNPssJQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://www.simpleandeasycodes.com/feeds/3348237380686917396/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.simpleandeasycodes.com/2011/11/sqlstate42601.html#comment-form" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/3348237380686917396?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/8882377031456587900/posts/default/3348237380686917396?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/SimpleAndEasyCodes/~3/QIyzlNPssJQ/sqlstate42601.html" title="SQLSTATE=42601" /><author><name>Madan</name><uri>http://www.blogger.com/profile/05020140911511710072</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="24" src="http://1.bp.blogspot.com/-flS3R6HtMMI/Tr6-XEzQTgI/AAAAAAAAAc0/R9UUe4-NHGM/s220/Photo0158.jpg" /></author><thr:total>0</thr:total><feedburner:origLink>http://www.simpleandeasycodes.com/2011/11/sqlstate42601.html</feedburner:origLink></entry></feed>

