<?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>The World Of Gavin &#187; string</title>
	<atom:link href="http://www.gavinwillingham.com/tag/string/feed" rel="self" type="application/rss+xml" />
	<link>http://www.gavinwillingham.com</link>
	<description>My opinions on things I have opinions on</description>
	<lastBuildDate>Fri, 28 Jan 2011 17:08:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Empty or null String in Java</title>
		<link>http://www.gavinwillingham.com/empty-or-null-string-in-java.html</link>
		<comments>http://www.gavinwillingham.com/empty-or-null-string-in-java.html#comments</comments>
		<pubDate>Wed, 23 Sep 2009 15:45:54 +0000</pubDate>
		<dc:creator>gavin</dc:creator>
				<category><![CDATA[IT]]></category>
		<category><![CDATA[Programming]]></category>
		<category><![CDATA[apache commons]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://www.gavinwillingham.com/?p=139</guid>
		<description><![CDATA[It’s such a common bit of code that crops up everywhere. That familiar line: if(var != null &#38;&#38; var.length() &#62; 0) There are slight variations. Some use if(var != null &#38;&#38; !var.equals("")) They’re all there to achieve the same purpose: check whether a String is null or empty. I&#8217;ve always thought &#8220;there really should be [...]]]></description>
			<content:encoded><![CDATA[<p>It’s such a common bit of code that crops up everywhere. That familiar line:</p>
<p><code> </code></p>
<pre>if(var != null &amp;&amp; var.length() &gt; 0)</pre>
<p>There are slight variations. Some use</p>
<p><code> </code></p>
<pre>if(var != null &amp;&amp; !var.equals(""))</pre>
<p>They’re all there to achieve the same purpose: check whether a String is null or empty.</p>
<p>I&#8217;ve always thought &#8220;there really should be a utility for this&#8221;, but written the code anyway. Today, when faced with repeating this pattern about 10 times, I finally decided to go and check the <a title="Apache Commons Lang javadoc" href="http://commons.apache.org/lang/api/index.html">Apache Commons Lang javadoc</a> and see if there was such a method. Unsurprisingly, there is, in <a title="StringUtils javadoc" href="http://commons.apache.org/lang/api/org/apache/commons/lang/StringUtils.html">StringUtils</a>.</p>
<p>There&#8217;s actually a few:</p>
<ul>
<li>
<pre>isBlank(String)</pre>
</li>
<li>
<pre>isEmpty(String)</pre>
</li>
</ul>
<ul>
<li>
<pre>isNotBlank(String)</pre>
</li>
<li>
<pre>isNotEmpty(String)</pre>
</li>
</ul>
<p>Very handy.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.gavinwillingham.com/empty-or-null-string-in-java.html/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

