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

<channel>
	<title>zParacha.com &#187; Programming</title>
	<atom:link href="http://www.zparacha.com/category/programming/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.zparacha.com</link>
	<description>Effective programming and blogging tips by Zaheer Paracha</description>
	<lastBuildDate>Wed, 09 Nov 2011 00:52:38 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>How to redirect homepage in Joomla</title>
		<link>http://www.zparacha.com/how-to-redirect-homepage-in-joomla/</link>
		<comments>http://www.zparacha.com/how-to-redirect-homepage-in-joomla/#comments</comments>
		<pubDate>Tue, 08 Nov 2011 18:29:18 +0000</pubDate>
		<dc:creator>Zaheer Paracha</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Web Development]]></category>
		<category><![CDATA[Joomla]]></category>

		<guid isPermaLink="false">http://www.zparacha.com/how-to-redirect-homepage-in-joomla/</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/how-to-redirect-homepage-in-joomla/' addthis:title='How to redirect homepage in Joomla' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div>Joomla is a wonderful platform to publish websites. With readily available templates you can have your website up and running in no time. Sometimes though you may need to direct your visitors to a different page than your regular home page, for instance you may want to direct all the visitors to a promotion page [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/how-to-redirect-homepage-in-joomla/' addthis:title='How to redirect homepage in Joomla' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div><p><a href="http://www.zparacha.com/how-to-redirect-homepage-in-joomla/">How to redirect homepage in Joomla</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>



<span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/how-to-limit-number-of-posts-on-your-wordpress-homepage/' rel='bookmark' title='Permanent Link: How to limit number of posts on your WordPress homepage.'>How to limit number of posts on your WordPress homepage.</a> <small>If you have been blogging regularly for more than few...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/how-to-redirect-homepage-in-joomla/' addthis:title='How to redirect homepage in Joomla' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div><p><!--adsense#greyLeft--><br />
Joomla is a wonderful platform to publish websites. With readily available templates you can have your website up and running in no time. Sometimes though you may need to direct your visitors to a different page than your regular home page, for instance you may want to direct all the visitors to a promotion page during special sales events. There is a very simple and easy way of doing this in Joomla.<span id="more-1338"></span></p>
<ol>
<li>Create and upload the standalone webpage to your domain.
	</li>
<li>
Backup your index.php file in templates/YOUR_TEMPLATE_FOLDER.	</li>
<li>
<p>Add following lines to the index.php file under the templates/YOUR_TEMPLATE_FOLDER.</li>
<pre name="code" class="php">
<?php
if ( JURI::base()==JURI::current() )
 { header( 'Location: http://www.yourdomainname.com/NEW_PAGE.php' ); }
?></pre>
</ol>
<p>Now when the visitors come to your website they will be taken to NEW_PAGE.php.<br />
After the need to redirect the traffic is over simply replace the index.php file with the file you backed up in step 1.</p>
<p>Happy coding..<br />
<!--adsense#tla-->
<div class="tweetmeme_button" style="float:right; margin: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.zparacha.com%2Fhow-to-redirect-homepage-in-joomla%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.zparacha.com%2Fhow-to-redirect-homepage-in-joomla%2F&amp;source=zparacha&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" title="How to redirect homepage in Joomla" alt=" How to redirect homepage in Joomla" /><br />
			</a>
		</div>
<p><a href="http://www.zparacha.com/how-to-redirect-homepage-in-joomla/">How to redirect homepage in Joomla</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'How to redirect homepage in Joomla on zParacha.com: Effective Programming tips',url: 'http://www.zparacha.com/how-to-redirect-homepage-in-joomla/',contentID: 'post-1338',signature: 'If you enjoyed this post, make sure you subscribe to my &lt;a href=\&quot;http://www.zparacha.com/feed/\&quot;&gt; RSS feed&lt;/a&gt;.',suggestTags: 'Joomla',providerName: 'zParacha.com: Effective Programming tips',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-vert.png" class="evernoteSiteMemoryButton" title="How to redirect homepage in Joomla" alt="article clipper vert How to redirect homepage in Joomla" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/how-to-redirect-homepage-in-joomla/' addthis:title='How to redirect homepage in Joomla' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div>

<p><span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/how-to-limit-number-of-posts-on-your-wordpress-homepage/' rel='bookmark' title='Permanent Link: How to limit number of posts on your WordPress homepage.'>How to limit number of posts on your WordPress homepage.</a> <small>If you have been blogging regularly for more than few...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.zparacha.com/how-to-redirect-homepage-in-joomla/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>How to search for a string in a file using Java regular expression.</title>
		<link>http://www.zparacha.com/search-string-file-java-regular-expression/</link>
		<comments>http://www.zparacha.com/search-string-file-java-regular-expression/#comments</comments>
		<pubDate>Wed, 29 Jul 2009 04:47:19 +0000</pubDate>
		<dc:creator>Zaheer</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.zparacha.com/?p=478</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/search-string-file-java-regular-expression/' addthis:title='How to search for a string in a file using Java regular expression.' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div>If you need to search for a phrase or a string in a text file Java regular expression is the easiest way to accomplish this task. Here is a simple example that demonstrates how you can use Java regular expression to find a string or a phrase in a text file. import java.io.File; import java.io.FileNotFoundException; [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/search-string-file-java-regular-expression/' addthis:title='How to search for a string in a file using Java regular expression.' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div><p><a href="http://www.zparacha.com/search-string-file-java-regular-expression/">How to search for a string in a file using Java regular expression.</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>



<span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/ultimate-java-regular-expression-to-validate-email-address/' rel='bookmark' title='Permanent Link: Ultimate Java Regular Expression to validate any email address.'>Ultimate Java Regular Expression to validate any email address.</a> <small>My post about Java regular expression gets a lot of...</small></li>
<li><a href='http://www.zparacha.com/how-to-validate-date-using-java-regular-expression/' rel='bookmark' title='Permanent Link: How to validate date using Java regular expression'>How to validate date using Java regular expression</a> <small>My earlier post on how to validate email address, SSN...</small></li>
<li><a href='http://www.zparacha.com/how-to-write-to-properties-file-in-java/' rel='bookmark' title='Permanent Link: How to write to properties file in Java'>How to write to properties file in Java</a> <small>One of most visited posts on this blog is How...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/search-string-file-java-regular-expression/' addthis:title='How to search for a string in a file using Java regular expression.' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div><p><!--adsense#top--><br />
If you need to search for a phrase or a string in a text file Java regular expression is the easiest way to accomplish this task. Here is a simple example that demonstrates how you can use Java regular expression to find a string or a phrase in a text file.<br />
<span id="more-478"></span></p>
<pre name="code" class="java">
import java.io.File;
import java.io.FileNotFoundException;
import java.util.Scanner;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.ArrayList;
import java.io.IOException;
public class TextSearch{
	public ArrayList<Integer> searchString(String fileName,
                                            String phrase) throws IOException{
	  Scanner fileScanner = new Scanner(new File(fileName));
	  int lineID = 0;
	  ArrayList<Integer> lineNumbers = new ArrayList<Integer>();
	  Pattern pattern =  Pattern.compile(phrase);//,Pattern.CASE_INSENSITIVE);
	  Matcher matcher = null;
	  while(fileScanner.hasNextLine()){
			String line = fileScanner.nextLine();
			lineID++;
			matcher = pattern.matcher(line);
			if(matcher.find()){
				lineNumbers.add(lineID);

			}

		}
		return lineNumbers;
	}
}
</pre>
<p>Here in this example I read input file line by line searching for the given string or phrase. The code uses Pattern and Matcher classes to search for the string. If a line contains the string we are looking for we store its line number in an ArrayList. At the end, the method returns the ArrayList of Integer objects depicting the lines of the file that have the given string. If the file does not contain given string an appropriate message will be printed.</p>
<p><!--adsense#tla--></p>
<div class="tweetmeme_button" style="float:right; margin: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.zparacha.com%2Fsearch-string-file-java-regular-expression%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.zparacha.com%2Fsearch-string-file-java-regular-expression%2F&amp;source=zparacha&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" title="How to search for a string in a file using Java regular expression." alt=" How to search for a string in a file using Java regular expression." /><br />
			</a>
		</div>
<p><a href="http://www.zparacha.com/search-string-file-java-regular-expression/">How to search for a string in a file using Java regular expression.</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'How to search for a string in a file using Java regular expression. on zParacha.com: Effective Programming tips',url: 'http://www.zparacha.com/search-string-file-java-regular-expression/',contentID: 'post-478',signature: 'If you enjoyed this post, make sure you subscribe to my &lt;a href=\&quot;http://www.zparacha.com/feed/\&quot;&gt; RSS feed&lt;/a&gt;.',suggestTags: '',providerName: 'zParacha.com: Effective Programming tips',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-vert.png" class="evernoteSiteMemoryButton" title="How to search for a string in a file using Java regular expression." alt="article clipper vert How to search for a string in a file using Java regular expression." />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/search-string-file-java-regular-expression/' addthis:title='How to search for a string in a file using Java regular expression.' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div>

<p><span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/ultimate-java-regular-expression-to-validate-email-address/' rel='bookmark' title='Permanent Link: Ultimate Java Regular Expression to validate any email address.'>Ultimate Java Regular Expression to validate any email address.</a> <small>My post about Java regular expression gets a lot of...</small></li>
<li><a href='http://www.zparacha.com/how-to-validate-date-using-java-regular-expression/' rel='bookmark' title='Permanent Link: How to validate date using Java regular expression'>How to validate date using Java regular expression</a> <small>My earlier post on how to validate email address, SSN...</small></li>
<li><a href='http://www.zparacha.com/how-to-write-to-properties-file-in-java/' rel='bookmark' title='Permanent Link: How to write to properties file in Java'>How to write to properties file in Java</a> <small>One of most visited posts on this blog is How...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.zparacha.com/search-string-file-java-regular-expression/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>How to read properties file in Spring.</title>
		<link>http://www.zparacha.com/how-to-read-properties-file-in-spring/</link>
		<comments>http://www.zparacha.com/how-to-read-properties-file-in-spring/#comments</comments>
		<pubDate>Sat, 24 Jan 2009 04:39:31 +0000</pubDate>
		<dc:creator>Zaheer</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[Spring]]></category>

		<guid isPermaLink="false">http://www.zparacha.com/?p=313</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/how-to-read-properties-file-in-spring/' addthis:title='How to read properties file in Spring.' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div>If you need to read properties file in your Spring application all you need is to configure a PropertyPlaceholderConfigurer bean in your application context. Following example shows how to read property values from a properties file named config.properties. This file needs to be in your classpath so Spring can find it. Let&#8217;s begin by creating [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/how-to-read-properties-file-in-spring/' addthis:title='How to read properties file in Spring.' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div><p><a href="http://www.zparacha.com/how-to-read-properties-file-in-spring/">How to read properties file in Spring.</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>



<span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/how-to-read-properties-file-in-java/' rel='bookmark' title='Permanent Link: How to read properties file in Java.'>How to read properties file in Java.</a> <small>Reading properties file in Java is much easier than you...</small></li>
<li><a href='http://www.zparacha.com/how-to-write-to-properties-file-in-java/' rel='bookmark' title='Permanent Link: How to write to properties file in Java'>How to write to properties file in Java</a> <small>One of most visited posts on this blog is How...</small></li>
<li><a href='http://www.zparacha.com/configure-multiple-handlers-spring-mvc-web-application/' rel='bookmark' title='Permanent Link: How to configure multiple handlers in a Spring MVC web application'>How to configure multiple handlers in a Spring MVC web application</a> <small>In Spring MVC, DispatcherServlet relies on handler mapping to determine...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/how-to-read-properties-file-in-spring/' addthis:title='How to read properties file in Spring.' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div><p><!--adsense#top--><br />
<!-- google_ad_section_start --><br />
If you need to read properties file in your Spring application all you need is to configure a <strong>PropertyPlaceholderConfigurer</strong> bean in your application context.<br />
Following example shows how to read property values from a properties file named <em>config.properties</em>. This file needs to be in your classpath so Spring can find it.</p>
<p>Let&#8217;s begin by creating a simple Java class that will use the properties values from the file.<br />
<!-- google_ad_section_end --></p>
<pre name="code" class="java">
package com.zparacha.spring.examples.config;

public class CreateUser {
	//Spring will populate these fields through Dependency Injection.
        private String name;
	private String email;
	private String URL;

	public CreateUser(){}
	public String getName() {
	  return name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getURL() {
		return URL;
	}

	public void setURL(String url) {
		URL = url;
	}
	public void displayUser() {
		System.out.println("Name=" + this.name);
		System.out.println("Email="+ this.email);
		System.out.println("URL=" + this.URL);
	}
}
</pre>
<p><span id="more-313"></span><br />
Now create the application context. I saved the file as <em>user.xml</em></p>
<pre name="code" class="html">
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
       xmlns:p="http://www.springframework.org/schema/p"
       xsi:schemaLocation="http://www.springframework.org/schema/beans
       http://www.springframework.org/schema/beans/spring-beans-2.5.xsd">
   <!--Bean to load properties file -->
   <bean id="placeholderConfig"
       class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
<property name="location"
       value="classpath:config.properties" />  <!--reads config.properties file-->
   </bean>
  <bean id="createUser"
      class="com.zparacha.spring.examples.config.CreateUser">
    <!--reference values read by PropertyPlaceholderConfigurer bean-->
<property name="name" value="${name}"/>
<property name="email" value="${email}"/>
<property name="URL" value="${URL}"/>
  </bean>
</beans>
</pre>
<p><!-- google_ad_section_start --><br />
Notice the <strong>placeholderConfig</strong> bean. This is where we are instructing Spring container to load the values from <strong>config.properties</strong> file. You can name your will whatever you like.</p>
<p>Here is my <em>config.properties</em> file.</p>
<pre name="code" class="html">
name=John Doe
URL=http://www.zparacha.com
email=demo@zparacha.com
</pre>
<p><!--adsense#top--><br />
That is all there is to read the properties file.<br />
Following is a simple test client.<br />
<!-- google_ad_section_end --></p>
<pre name="code" class="java">
package com.zparacha.spring.examples.config;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class UserClient {
	public static void main(String[] args) throws Exception {
		String[] configFiles = new String[] { "user.xml" };
		BeanFactory factory =
			new ClassPathXmlApplicationContext (configFiles);
		CreateUser createUser =
	        (CreateUser) factory.getBean("createUser");
		createUser.displayUser();
	  }
}
</pre>
<p>If you execute this class it will print</p>
<pre name="code" class="html">
Name=John Doe
Email=demo@zparacha.com
URL=http://www.zparacha.com
</pre>
<p><!-- google_ad_section_start --><br />
This approach to use PropertyPlaceholderConfigurer to read properties file will not work if you are using <strong>XmlBeanFactory</strong>. To read properties file with <strong>XmlBeanFactory</strong> you will have to retrieve the bean from context and invoke it on your factory.<br />
<!-- google_ad_section_start --><br />
For example:<br />
<!--adsense#tla--></p>
<pre name="code" class="java">
package com.zparacha.spring.examples.config;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.context.support.ClassPathXmlApplicationContext;

public class UserClient2 {
	public static void main(String[] args) throws Exception {
		XmlBeanFactory factory =
			        new XmlBeanFactory(new ClassPathResource("hello.xml"));
			  PropertyPlaceholderConfigurer configurer = (PropertyPlaceholderConfigurer)factory.getBean("placeholderConfig");
	  configurer.postProcessBeanFactory(factory);
		CreateUser createUser =
	        (CreateUser) factory.getBean("createUser");
		createUser.displayUser();
	  }
}
</pre>
<p>Unless you have your reasons to use <strong>XmlBeanFactory</strong>, I would recommend that you use <strong>ClassPathXmlApplicationContext</strong> as your factory. </p>
<p>Enjoy.</p>
<div class="tweetmeme_button" style="float:right; margin: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.zparacha.com%2Fhow-to-read-properties-file-in-spring%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.zparacha.com%2Fhow-to-read-properties-file-in-spring%2F&amp;source=zparacha&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" title="How to read properties file in Spring." alt=" How to read properties file in Spring." /><br />
			</a>
		</div>
<p><a href="http://www.zparacha.com/how-to-read-properties-file-in-spring/">How to read properties file in Spring.</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'How to read properties file in Spring. on zParacha.com: Effective Programming tips',url: 'http://www.zparacha.com/how-to-read-properties-file-in-spring/',contentID: 'post-313',signature: 'If you enjoyed this post, make sure you subscribe to my &lt;a href=\&quot;http://www.zparacha.com/feed/\&quot;&gt; RSS feed&lt;/a&gt;.',suggestTags: '',providerName: 'zParacha.com: Effective Programming tips',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-vert.png" class="evernoteSiteMemoryButton" title="How to read properties file in Spring." alt="article clipper vert How to read properties file in Spring." />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/how-to-read-properties-file-in-spring/' addthis:title='How to read properties file in Spring.' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div>

<p><span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/how-to-read-properties-file-in-java/' rel='bookmark' title='Permanent Link: How to read properties file in Java.'>How to read properties file in Java.</a> <small>Reading properties file in Java is much easier than you...</small></li>
<li><a href='http://www.zparacha.com/how-to-write-to-properties-file-in-java/' rel='bookmark' title='Permanent Link: How to write to properties file in Java'>How to write to properties file in Java</a> <small>One of most visited posts on this blog is How...</small></li>
<li><a href='http://www.zparacha.com/configure-multiple-handlers-spring-mvc-web-application/' rel='bookmark' title='Permanent Link: How to configure multiple handlers in a Spring MVC web application'>How to configure multiple handlers in a Spring MVC web application</a> <small>In Spring MVC, DispatcherServlet relies on handler mapping to determine...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.zparacha.com/how-to-read-properties-file-in-spring/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>How to remove Ctrl-M (^M) from Unix files?</title>
		<link>http://www.zparacha.com/remove-ctrl-m/</link>
		<comments>http://www.zparacha.com/remove-ctrl-m/#comments</comments>
		<pubDate>Wed, 10 Dec 2008 03:04:23 +0000</pubDate>
		<dc:creator>Zaheer</dc:creator>
				<category><![CDATA[Programming]]></category>
		<category><![CDATA[Ctrl-M]]></category>
		<category><![CDATA[^M]]></category>

		<guid isPermaLink="false">http://www.zparacha.com/?p=201</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/remove-ctrl-m/' addthis:title='How to remove Ctrl-M (^M) from Unix files?' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div>Sometimes when you upload or FTP files from a Windows system to a UNIX box you will see ^M at the end of each line. ^M is the UNIX equivalent of DOS line break. Not only does it not look pretty, this extra character may break all sorts of scripts that you try to run [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/remove-ctrl-m/' addthis:title='How to remove Ctrl-M (^M) from Unix files?' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div><p><a href="http://www.zparacha.com/remove-ctrl-m/">How to remove Ctrl-M (^M) from Unix files?</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>



<span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/remove-eclipse-workspace-dropdown-list/' rel='bookmark' title='Permanent Link: How to remove (delete) Eclipse workspace from the dropdown list.'>How to remove (delete) Eclipse workspace from the dropdown list.</a> <small>Eclipse is my favorite Java IDE. To manage projects Eclipse...</small></li>
<li><a href='http://www.zparacha.com/share_files_with_dropbox/' rel='bookmark' title='Permanent Link: Share your files with DropBox'>Share your files with DropBox</a> <small>Everyone likes to share files and photos online with friends...</small></li>
<li><a href='http://www.zparacha.com/include-externaljar-file-in-maven/' rel='bookmark' title='Permanent Link: How to add external jar files to Maven project POM'>How to add external jar files to Maven project POM</a> <small>Maven has made compiling Java projects almost an effortless job....</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/remove-ctrl-m/' addthis:title='How to remove Ctrl-M (^M) from Unix files?' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div><p><img class="alignright"  src="http://www.zparacha.com/images/no_caret_m.png" style="border:0px;" title="How to remove Ctrl M (^M) from Unix files?" alt="no caret m How to remove Ctrl M (^M) from Unix files?" />Sometimes when you upload or FTP files from a Windows system to a UNIX box you will see <b>^M</b> at the end of each line. <b>^M</b> is the UNIX equivalent of DOS line break. Not only does it not look pretty, this extra character may break all sorts of scripts that you try to run on your file. So how do you remove ^M? Here are two ways to get rid or ^M (Ctrl-M) from your files.<span id="more-201"></span></p>
<p><b>Option 1.</b>Use <b>dos2unix</b> utility. The easiest way is to use dos2unix utility.<br />
  <code style="background-color:#c4c6c5;"> dos2unix originalfile convertedfile.</code></p>
<p> You can run <code style="background-color:#c4c6c5;"> man dos2unix</code> to learn about all the options.<br />
<!--adsense#green1--><br />
<b>Option 2.</b> If you do not have dos2unix utility the next best option is to edit the file in VI. Open the file in VI editor and do a global search and replace.<br />
<code style="background-color:#c4c6c5;">:%s/(ctrl+V)(ctrl+M)//g </code> and hit enter.</p>
<p>Be aware that <b>^M</b> is not just a <b>^</b> followed by a <b>M</b>. You will have to press <b>CTRL</b> and <b>V</b> to get <b>^</b> and then <b>CRTL</b> and <b>M</b> to get the <b>M</b>.<br />
After replacing ^M do :wq or ZZ to save and exit the VI editor.<br />
Enjoy.</p>
<div class="tweetmeme_button" style="float:right; margin: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.zparacha.com%2Fremove-ctrl-m%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.zparacha.com%2Fremove-ctrl-m%2F&amp;source=zparacha&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" title="How to remove Ctrl M (^M) from Unix files?" alt=" How to remove Ctrl M (^M) from Unix files?" /><br />
			</a>
		</div>
<p><a href="http://www.zparacha.com/remove-ctrl-m/">How to remove Ctrl-M (^M) from Unix files?</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'How to remove Ctrl-M (^M) from Unix files? on zParacha.com: Effective Programming tips',url: 'http://www.zparacha.com/remove-ctrl-m/',contentID: 'post-201',signature: 'If you enjoyed this post, make sure you subscribe to my &lt;a href=\&quot;http://www.zparacha.com/feed/\&quot;&gt; RSS feed&lt;/a&gt;.',suggestTags: 'Ctrl-M,^M',providerName: 'zParacha.com: Effective Programming tips',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-vert.png" class="evernoteSiteMemoryButton" title="How to remove Ctrl M (^M) from Unix files?" alt="article clipper vert How to remove Ctrl M (^M) from Unix files?" />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/remove-ctrl-m/' addthis:title='How to remove Ctrl-M (^M) from Unix files?' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div>

<p><span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/remove-eclipse-workspace-dropdown-list/' rel='bookmark' title='Permanent Link: How to remove (delete) Eclipse workspace from the dropdown list.'>How to remove (delete) Eclipse workspace from the dropdown list.</a> <small>Eclipse is my favorite Java IDE. To manage projects Eclipse...</small></li>
<li><a href='http://www.zparacha.com/share_files_with_dropbox/' rel='bookmark' title='Permanent Link: Share your files with DropBox'>Share your files with DropBox</a> <small>Everyone likes to share files and photos online with friends...</small></li>
<li><a href='http://www.zparacha.com/include-externaljar-file-in-maven/' rel='bookmark' title='Permanent Link: How to add external jar files to Maven project POM'>How to add external jar files to Maven project POM</a> <small>Maven has made compiling Java projects almost an effortless job....</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.zparacha.com/remove-ctrl-m/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Print large string in PL/SQL.</title>
		<link>http://www.zparacha.com/print-large-string-in-plsql/</link>
		<comments>http://www.zparacha.com/print-large-string-in-plsql/#comments</comments>
		<pubDate>Wed, 02 Jul 2008 00:44:00 +0000</pubDate>
		<dc:creator>Zaheer</dc:creator>
				<category><![CDATA[Programming]]></category>

		<guid isPermaLink="false">http://www.zparacha.com/?p=109</guid>
		<description><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/print-large-string-in-plsql/' addthis:title='Print large string in PL/SQL.' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div>For PL/SQL developers put_line is a quite useful method. I use it for logging purposes. Recently I found out that the method has an annoying limitation. You cannot print more than 255 characters per line! Now that is a strange feature. I don&#8217;t know what is the reasoning behind this restriction but it does make [...]<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/print-large-string-in-plsql/' addthis:title='Print large string in PL/SQL.' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div><p><a href="http://www.zparacha.com/print-large-string-in-plsql/">Print large string in PL/SQL.</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>



<span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/extract-substring-from-end-of-a-java-string/' rel='bookmark' title='Permanent Link: Extract substring from end of a Java String'>Extract substring from end of a Java String</a> <small>Today I&#8217;ll show you how to extract last few characters...</small></li>
<li><a href='http://www.zparacha.com/search-string-file-java-regular-expression/' rel='bookmark' title='Permanent Link: How to search for a string in a file using Java regular expression.'>How to search for a string in a file using Java regular expression.</a> <small>If you need to search for a phrase or a...</small></li>
<li><a href='http://www.zparacha.com/best-way-to-check-if-a-java-string-is-a-number/' rel='bookmark' title='Permanent Link: Best way to check if a Java String is a number.'>Best way to check if a Java String is a number.</a> <small>An example on how to validate if a String variable...</small></li>
</ul>]]></description>
			<content:encoded><![CDATA[<div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/print-large-string-in-plsql/' addthis:title='Print large string in PL/SQL.' ><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a></div><p>For PL/SQL developers <em>put_line</em> is a quite useful method. I use it for logging purposes. Recently I found out that the method has an annoying limitation. You cannot print more than 255 characters per line!<br />
Now that is a strange feature. I don&#8217;t know what is the reasoning behind this restriction but it does make this method somewhat risky to use. Because if you use put_line to log a string more than 255 characters long it will raise an exception and you program might fail. Unless you catch the exception and continue on with your flow. Obviously no good programmer would want the trouble of adding exception handling code for such a mundane task as logging. So far I have not found an alternative method to print out large string in PL/SQL  but I came up with a work around.<br />
I created a little procedure to print large string. </p>
<p><!--adsense#tla--><br />
Here is the method. <span id="more-109"></span><br />
</p>
<pre lang="sql">
PROCEDURE print_line(p_str IN VARCHAR2) IS
l_offset NUMBER;
l_length NUMBER;
l_max_len NUMBER;
l_line VARCHAR2(256);
BEGIN
 l_offset :=1;
 l_max_len :=255;
 l_length:=LENGTH(p_str);
dbms_output.put_line(l_length);
 WHILE l_offset <= l_length LOOP
	   l_str := SUBSTR(p_str,  l_offset,
	                         l_max_len);
	   l_offset := l_offset+l_max_len;
      dbms_output.put_line(l_line);
    END LOOP;
 END;
</pre>
<p>Let's now write a simple test client to see this method in action.</p>
<pre lang="sql">
DECLARE
l_str VARCHAR2(3000);
l_phrase VARCHAR2(300);
BEGIN
l_phrase :=' The quick brown fox jumps over the lazy dog';
--Create a string bigger than 255 characters.
FOR i IN 1..20 LOOP
 l_str := l_str || l_phrase;
END LOOP;
l_length:=LENGTH(l_str);
dbms_output.put_line(l_length); -- The string has 880 characters.
--dbms_output.put_line(l_str); //Cannot do this. You will get following error.
/*
ORA-20000: ORU-10028: line length overflow, limit of 255 chars per line
ORA-06512: at "SYS.DBMS_OUTPUT", line 35
ORA-06512: at "SYS.DBMS_OUTPUT", line 133
ORA-06512: at line 15
*/
 --Now try our method.
  print_line(l_str);
END;
</pre>
<p>Here is the output<br />
 /*<br />
  The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog The quick brown fox jumps over the<br />
 lazy dog The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog The quick brown fox jumps<br />
 over the lazy dog The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog The quick brown<br />
fox jumps over the lazy dog The quick brown fox jumps over the lazy dog The quick brown fox jumps over the lazy dog<br />
 */</p>
<p><!--adsense#tla--><br />
Feel free to copy, modify and use this method. If you know a better way of achieving this please let me know.</p>
<div class="tweetmeme_button" style="float:right; margin: 10px;">
			<a href="http://api.tweetmeme.com/share?url=http%3A%2F%2Fwww.zparacha.com%2Fprint-large-string-in-plsql%2F"><br />
				<img src="http://api.tweetmeme.com/imagebutton.gif?url=http%3A%2F%2Fwww.zparacha.com%2Fprint-large-string-in-plsql%2F&amp;source=zparacha&amp;style=normal&amp;service=bit.ly&amp;b=2" height="61" width="50" title="Print large string in PL/SQL." alt=" Print large string in PL/SQL." /><br />
			</a>
		</div>
<p><a href="http://www.zparacha.com/print-large-string-in-plsql/">Print large string in PL/SQL.</a> is a post from: <a href="http://www.zparacha.com">zParacha.com | Effective programming and blogging tips by Zaheer Paracha</a></p>
<div class="evernoteSiteMemory"><a href="javascript:" onclick="Evernote.doClip({title: 'Print large string in PL/SQL. on zParacha.com: Effective Programming tips',url: 'http://www.zparacha.com/print-large-string-in-plsql/',contentID: 'post-109',signature: 'If you enjoyed this post, make sure you subscribe to my &lt;a href=\&quot;http://www.zparacha.com/feed/\&quot;&gt; RSS feed&lt;/a&gt;.',suggestTags: '',providerName: 'zParacha.com: Effective Programming tips',styling: 'text' });return false" class="evernoteSiteMemoryLink"><img src="http://static.evernote.com/article-clipper-vert.png" class="evernoteSiteMemoryButton" title="Print large string in PL/SQL." alt="article clipper vert Print large string in PL/SQL." />
				</a>				<div class="evernoteSiteMemoryClear">&nbsp;</div>
</div><div class="addthis_toolbox addthis_default_style addthis_32x32_style" addthis:url='http://www.zparacha.com/print-large-string-in-plsql/' addthis:title='Print large string in PL/SQL.' ><a class="addthis_button_googlereader"></a><a class="addthis_button_email"></a><a class="addthis_button_google"></a><a class="addthis_button_twitter"></a><a class="addthis_button_google_plusone"></a><a class="addthis_button_facebook_like"></a><a class="addthis_button_compact"></a></div>

<p><span style="font-weight:bold;"> Related posts:</span><ul><li><a href='http://www.zparacha.com/extract-substring-from-end-of-a-java-string/' rel='bookmark' title='Permanent Link: Extract substring from end of a Java String'>Extract substring from end of a Java String</a> <small>Today I&#8217;ll show you how to extract last few characters...</small></li>
<li><a href='http://www.zparacha.com/search-string-file-java-regular-expression/' rel='bookmark' title='Permanent Link: How to search for a string in a file using Java regular expression.'>How to search for a string in a file using Java regular expression.</a> <small>If you need to search for a phrase or a...</small></li>
<li><a href='http://www.zparacha.com/best-way-to-check-if-a-java-string-is-a-number/' rel='bookmark' title='Permanent Link: Best way to check if a Java String is a number.'>Best way to check if a Java String is a number.</a> <small>An example on how to validate if a String variable...</small></li>
</ul></p>]]></content:encoded>
			<wfw:commentRss>http://www.zparacha.com/print-large-string-in-plsql/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

