<?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>MIRACLE CODES</title>
	<atom:link href="http://www.miraclecodes.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://www.miraclecodes.com</link>
	<description>The code that saves the day!</description>
	<lastBuildDate>Fri, 11 May 2012 07:18:44 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.2</generator>
		<item>
		<title>Replace Turkish Characters in Java &#8211; Method 2</title>
		<link>http://www.miraclecodes.com/?p=199</link>
		<comments>http://www.miraclecodes.com/?p=199#comments</comments>
		<pubDate>Wed, 09 May 2012 12:16:51 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Codes]]></category>

		<guid isPermaLink="false">http://www.miraclecodes.com/?p=199</guid>
		<description><![CDATA[1 2 3 4 5 6 7 8 9 public static String clearTurkishChars&#40;String str&#41; &#123; String ret = str; char&#91;&#93; turkishChars = new char&#91;&#93; &#123;0x131, 0x130, 0xFC, 0xDC, 0xF6, 0xD6, 0x15F, 0x15E, 0xE7, 0xC7, 0x11F, 0x11E&#125;; char&#91;&#93; englishChars = new char&#91;&#93; &#123;'i', 'I', 'u', 'U', 'o', 'O', 's', 'S', 'c', 'C', 'g', 'G'&#125;; for &#40;int [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> clearTurkishChars<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> str<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #003399;">String</span> ret <span style="color: #339933;">=</span> str<span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">char</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> turkishChars <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">char</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span>0x131, 0x130, 0xFC, 0xDC, 0xF6, 0xD6, 0x15F, 0x15E, 0xE7, 0xC7, 0x11F, 0x11E<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">char</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> englishChars <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">char</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #009900;">&#123;</span><span style="color: #0000ff;">'i'</span>, <span style="color: #0000ff;">'I'</span>, <span style="color: #0000ff;">'u'</span>, <span style="color: #0000ff;">'U'</span>, <span style="color: #0000ff;">'o'</span>, <span style="color: #0000ff;">'O'</span>, <span style="color: #0000ff;">'s'</span>, <span style="color: #0000ff;">'S'</span>, <span style="color: #0000ff;">'c'</span>, <span style="color: #0000ff;">'C'</span>, <span style="color: #0000ff;">'g'</span>, <span style="color: #0000ff;">'G'</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&lt;</span> turkishChars.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		ret <span style="color: #339933;">=</span> ret.<span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">char</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span>turkishChars<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>, <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">String</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">char</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#123;</span>englishChars<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">return</span> ret<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.miraclecodes.com/?feed=rss2&#038;p=199</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Remove Xml/Html Tags from Java String</title>
		<link>http://www.miraclecodes.com/?p=195</link>
		<comments>http://www.miraclecodes.com/?p=195#comments</comments>
		<pubDate>Wed, 09 May 2012 12:13:24 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Codes]]></category>

		<guid isPermaLink="false">http://www.miraclecodes.com/?p=195</guid>
		<description><![CDATA[1 2 3 public String removeXmlTags&#40;String str&#41; &#123; return str.replaceAll&#40;&#34;\\&#60;.*?\\&#62;&#34;, &#34;&#34;&#41;.trim&#40;&#41;; &#125;]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> removeXmlTags<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> str<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">return</span> str.<span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>&lt;.*?<span style="color: #000099; font-weight: bold;">\\</span>&gt;&quot;</span>, <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.miraclecodes.com/?feed=rss2&#038;p=195</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Replace Turkish Characters in Java – Method 1</title>
		<link>http://www.miraclecodes.com/?p=189</link>
		<comments>http://www.miraclecodes.com/?p=189#comments</comments>
		<pubDate>Wed, 09 May 2012 12:05:55 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Codes]]></category>

		<guid isPermaLink="false">http://www.miraclecodes.com/?p=189</guid>
		<description><![CDATA[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 public String clearTurkishCharacters&#40;String str&#41; &#123; if &#40;str != null&#41;&#123; str = str.replaceAll&#40;&#34;&#38;#304;&#34;, &#34;\u0130&#34;&#41;; str = str.replaceAll&#40;&#34;&#38;#214;&#34;, &#34;\u00d6&#34;&#41;; str = str.replaceAll&#40;&#34;&#38;#350;&#34;, &#34;\u015e&#34;&#41;; str = str.replaceAll&#40;&#34;&#38;#220;&#34;, &#34;\u00dc&#34;&#41;; str = str.replaceAll&#40;&#34;&#38;#199;&#34;, &#34;\u00c7&#34;&#41;; str = str.replaceAll&#40;&#34;&#38;#286;&#34;, &#34;\u011E&#34;&#41;; str = str.replaceAll&#40;&#34;&#38;#252;&#34;, &#34;\u00fc&#34;&#41;; str [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> clearTurkishCharacters<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> str<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>str <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
		str <span style="color: #339933;">=</span> str.<span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;#304;&quot;</span>, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>0130&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		str <span style="color: #339933;">=</span> str.<span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;#214;&quot;</span>, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>00d6&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		str <span style="color: #339933;">=</span> str.<span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;#350;&quot;</span>, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>015e&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		str <span style="color: #339933;">=</span> str.<span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;#220;&quot;</span>, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>00dc&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		str <span style="color: #339933;">=</span> str.<span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;#199;&quot;</span>, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>00c7&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		str <span style="color: #339933;">=</span> str.<span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;#286;&quot;</span>, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>011E&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		str <span style="color: #339933;">=</span> str.<span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;#252;&quot;</span>, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>00fc&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		str <span style="color: #339933;">=</span> str.<span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;#287;&quot;</span>, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>011f&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		str <span style="color: #339933;">=</span> str.<span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;#351;&quot;</span>, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>015f&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		str <span style="color: #339933;">=</span> str.<span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;#231;&quot;</span>, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>00e7&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		str <span style="color: #339933;">=</span> str.<span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;#246;&quot;</span>, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>00f6&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		str <span style="color: #339933;">=</span> str.<span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&amp;#305;&quot;</span>, <span style="color: #0000ff;">&quot;<span style="color: #000099; font-weight: bold;">\u</span>0131&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #000000; font-weight: bold;">return</span> str<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.miraclecodes.com/?feed=rss2&#038;p=189</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Caps Lock detection with SmartGWT</title>
		<link>http://www.miraclecodes.com/?p=184</link>
		<comments>http://www.miraclecodes.com/?p=184#comments</comments>
		<pubDate>Wed, 11 Apr 2012 07:25:27 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Codes]]></category>

		<guid isPermaLink="false">http://www.miraclecodes.com/?p=184</guid>
		<description><![CDATA[1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 final PasswordItem pwd = new PasswordItem&#40;&#41;; final StaticTextItem sti = new StaticTextItem&#40;&#41;; &#160; //... pwd.addChangedHandler&#40;new ChangedHandler&#40;&#41; &#123; @Override public void onChanged&#40;ChangedEvent event&#41; &#123; try &#123; int keycode = EventHandler.getKeyEventCharacterValue&#40;&#41;; [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">	<span style="color: #000000; font-weight: bold;">final</span> PasswordItem pwd <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> PasswordItem<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #000000; font-weight: bold;">final</span> StaticTextItem sti <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> StaticTextItem<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//...</span>
		pwd.<span style="color: #006633;">addChangedHandler</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> ChangedHandler<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			@Override
			<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> onChanged<span style="color: #009900;">&#40;</span>ChangedEvent event<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
					<span style="color: #000066; font-weight: bold;">int</span> keycode <span style="color: #339933;">=</span> EventHandler.<span style="color: #006633;">getKeyEventCharacterValue</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000066; font-weight: bold;">boolean</span> shift <span style="color: #339933;">=</span> EventHandler.<span style="color: #006633;">shiftKeyDown</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>shift <span style="color: #339933;">&amp;&amp;</span> keycode <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">65</span> <span style="color: #339933;">&amp;&amp;</span> keycode <span style="color: #339933;">&lt;=</span> <span style="color: #cc66cc;">90</span><span style="color: #009900;">&#41;</span>
						sti.<span style="color: #006633;">show</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
					<span style="color: #000000; font-weight: bold;">else</span> 
						sti.<span style="color: #006633;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
					sti.<span style="color: #006633;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				<span style="color: #009900;">&#125;</span>
			<span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//...</span>
&nbsp;
		sti.<span style="color: #006633;">setValue</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;nobr&gt;&amp;nbsp;Caps Lock is ON &amp;nbsp;&lt;/nobr&gt;&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		sti.<span style="color: #006633;">setCellStyle</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;hintstyle&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// some style with fancy warning sign...</span>
		sti.<span style="color: #006633;">setShowTitle</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #666666; font-style: italic;">//...</span>
		sti.<span style="color: #006633;">hide</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #666666; font-style: italic;">// this line must be after DynamicFrom.setItems commnad!</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.miraclecodes.com/?feed=rss2&#038;p=184</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Dirty Fix for FFMpeg&#8217;s Header Missing Issue</title>
		<link>http://www.miraclecodes.com/?p=179</link>
		<comments>http://www.miraclecodes.com/?p=179#comments</comments>
		<pubDate>Thu, 05 Apr 2012 06:48:38 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Codes]]></category>

		<guid isPermaLink="false">http://www.miraclecodes.com/?p=179</guid>
		<description><![CDATA[If you suffer from &#8220;Header missing&#8221; error while decoding your mp3 files with ffmpeg, you can try to change the libavcodec/mpegaudiodec.c file as follows, and recompile. (!use AYOR!) Edit: These changes are required for the ffmpeg in Xuggler 4 and not guaranteed to solve all problems. However ffmpeg in Xuggler 3.4 works fine. 1 2 [...]]]></description>
			<content:encoded><![CDATA[<p>If you suffer from &#8220;Header missing&#8221; error while decoding your mp3 files with ffmpeg, you can try to change the</p>
<p>libavcodec/mpegaudiodec.c</p>
<p>file as follows, and recompile. (!use AYOR!)</p>
<p>Edit: These changes are required for the ffmpeg in Xuggler 4 and not guaranteed to solve all problems. However ffmpeg in Xuggler 3.4 works fine.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
</pre></td><td class="code"><pre class="c" style="font-family:monospace;">&nbsp;
<span style="color: #339933;">#include &quot;libavformat/id3v1.h&quot;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//...</span>
&nbsp;
<span style="color: #993333;">static</span> <span style="color: #993333;">int</span> decode_frame<span style="color: #009900;">&#40;</span>AVCodecContext <span style="color: #339933;">*</span> avctx<span style="color: #339933;">,</span> <span style="color: #993333;">void</span> <span style="color: #339933;">*</span>data<span style="color: #339933;">,</span> <span style="color: #993333;">int</span> <span style="color: #339933;">*</span>got_frame_ptr<span style="color: #339933;">,</span> AVPacket <span style="color: #339933;">*</span>avpkt<span style="color: #009900;">&#41;</span>
<span style="color: #009900;">&#123;</span>
    <span style="color: #993333;">const</span> <span style="color: #993333;">uint8_t</span> <span style="color: #339933;">*</span>buf  <span style="color: #339933;">=</span> avpkt<span style="color: #339933;">-&gt;</span>data<span style="color: #339933;">;</span>
    <span style="color: #993333;">int</span> buf_size        <span style="color: #339933;">=</span> avpkt<span style="color: #339933;">-&gt;</span>size<span style="color: #339933;">;</span>
    MPADecodeContext <span style="color: #339933;">*</span>s <span style="color: #339933;">=</span> avctx<span style="color: #339933;">-&gt;</span>priv_data<span style="color: #339933;">;</span>
    <span style="color: #993333;">uint32_t</span> header<span style="color: #339933;">;</span>
    <span style="color: #993333;">int</span> out_size<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #666666; font-style: italic;">//++++</span>
    <span style="color: #b1b100;">while</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>buf_size <span style="color: #339933;">&lt;</span> HEADER_SIZE<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            av_log<span style="color: #009900;">&#40;</span>avctx<span style="color: #339933;">,</span> AV_LOG_DEBUG<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;buf_size&lt;header size. Ignore Packet<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #b1b100;">return</span> avpkt<span style="color: #339933;">-&gt;</span>size<span style="color: #339933;">;</span>
            <span style="color: #666666; font-style: italic;">//return AVERROR_INVALIDDATA;</span>
        <span style="color: #009900;">&#125;</span>
&nbsp;
        header <span style="color: #339933;">=</span> AV_RB32<span style="color: #009900;">&#40;</span>buf<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>ff_mpa_check_header<span style="color: #009900;">&#40;</span>header<span style="color: #009900;">&#41;</span> <span style="color: #339933;">&lt;</span> <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>buf_size <span style="color: #339933;">==</span> ID3v1_TAG_SIZE
                <span style="color: #339933;">&amp;&amp;</span> buf<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #ff0000;">'T'</span> <span style="color: #339933;">&amp;&amp;</span> buf<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #ff0000;">'A'</span> <span style="color: #339933;">&amp;&amp;</span> buf<span style="color: #009900;">&#91;</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">==</span> <span style="color: #ff0000;">'G'</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                s<span style="color: #339933;">-&gt;</span>frame_size <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
                <span style="color: #b1b100;">return</span> ID3v1_TAG_SIZE<span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
            <span style="color: #666666; font-style: italic;">//av_log(avctx, AV_LOG_ERROR, &quot;Header missing\n&quot;);</span>
            <span style="color: #666666; font-style: italic;">//return AVERROR_INVALIDDATA;</span>
        <span style="color: #009900;">&#125;</span> <span style="color: #b1b100;">else</span> <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</span>
        av_log<span style="color: #009900;">&#40;</span>avctx<span style="color: #339933;">,</span> AV_LOG_DEBUG<span style="color: #339933;">,</span> <span style="color: #ff0000;">&quot;Header missing, skipping one byte<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        buf<span style="color: #339933;">++;</span>
        buf_size<span style="color: #339933;">--;</span>
    <span style="color: #009900;">&#125;</span>
    <span style="color: #666666; font-style: italic;">// ---</span>
&nbsp;
    <span style="color: #b1b100;">if</span> <span style="color: #009900;">&#40;</span>avpriv_mpegaudio_decode_header<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>MPADecodeHeader <span style="color: #339933;">*</span><span style="color: #009900;">&#41;</span>s<span style="color: #339933;">,</span> header<span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #808080; font-style: italic;">/* free format: prepare to compute frame size */</span>
        s<span style="color: #339933;">-&gt;</span>frame_size <span style="color: #339933;">=</span> <span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
        <span style="color: #b1b100;">return</span> AVERROR_INVALIDDATA<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//</span>
<span style="color: #666666; font-style: italic;">//... rest is the same</span>
<span style="color: #666666; font-style: italic;">//</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.miraclecodes.com/?feed=rss2&#038;p=179</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Hash to Hex String (for DB Storage)</title>
		<link>http://www.miraclecodes.com/?p=173</link>
		<comments>http://www.miraclecodes.com/?p=173#comments</comments>
		<pubDate>Fri, 21 Oct 2011 14:04:08 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Codes]]></category>
		<category><![CDATA[Hash]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[SHA]]></category>

		<guid isPermaLink="false">http://www.miraclecodes.com/?p=173</guid>
		<description><![CDATA[1 String dbStoreableHash = new java.math.BigInteger&#40;1, MessageDigest.getInstance&#40;&#34;SHA&#34;&#41;.digest&#40;thePassword.getBytes&#40;&#41;&#41;&#41;.toString&#40;16&#41;;]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
</pre></td><td class="code"><pre class="java" style="font-family:monospace;"><span style="color: #003399;">String</span> dbStoreableHash <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> java.<span style="color: #006633;">math</span>.<span style="color: #003399;">BigInteger</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">1</span>, <span style="color: #003399;">MessageDigest</span>.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;SHA&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">digest</span><span style="color: #009900;">&#40;</span>thePassword.<span style="color: #006633;">getBytes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">16</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.miraclecodes.com/?feed=rss2&#038;p=173</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Binding the JNDI Initial Context from Standalone Application</title>
		<link>http://www.miraclecodes.com/?p=146</link>
		<comments>http://www.miraclecodes.com/?p=146#comments</comments>
		<pubDate>Thu, 14 Jul 2011 10:51:39 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Codes]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[JNDI]]></category>

		<guid isPermaLink="false">http://www.miraclecodes.com/?p=146</guid>
		<description><![CDATA[You can use the following code in your main function to create a datasource with the JNDI name which is usually used by the application server. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 InitialContext ic = null; OracleConnectionPoolDataSource ds = null; PropertyBase pmap = [...]]]></description>
			<content:encoded><![CDATA[<p>You can use the following code in your main function to create a datasource with the JNDI name which is usually used by the application server.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">            <span style="color: #003399;">InitialContext</span> ic <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
            OracleConnectionPoolDataSource ds <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
            PropertyBase pmap <span style="color: #339933;">=</span> PropertyBase.<span style="color: #006633;">getInstance</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
            <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                  <span style="color: #003399;">System</span>.<span style="color: #006633;">setProperty</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Context</span>.<span style="color: #006633;">INITIAL_CONTEXT_FACTORY</span>, <span style="color: #0000ff;">&quot;org.apache.naming.java.javaURLContextFactory&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                  <span style="color: #003399;">System</span>.<span style="color: #006633;">setProperty</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Context</span>.<span style="color: #006633;">URL_PKG_PREFIXES</span>, <span style="color: #0000ff;">&quot;org.apache.naming&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                  ic <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">InitialContext</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                  ds <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> OracleConnectionPoolDataSource<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                  ds.<span style="color: #006633;">setURL</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;jdbc:oracle:thin:@my_server_name:1521:SRV_NAME&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                  ds.<span style="color: #006633;">setUser</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;username&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                  ds.<span style="color: #006633;">setPassword</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;password&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
                  ic.<span style="color: #006633;">createSubcontext</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;jdbc&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                  ic.<span style="color: #006633;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;jdbc/MY_DS_NAME&quot;</span>, ds<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Exception</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                  logger.<span style="color: #006633;">error</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&quot;</span>, e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.miraclecodes.com/?feed=rss2&#038;p=146</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Posting UTF-8 Data with commons.httpclient.methods.PostMethod</title>
		<link>http://www.miraclecodes.com/?p=144</link>
		<comments>http://www.miraclecodes.com/?p=144#comments</comments>
		<pubDate>Thu, 14 Jul 2011 10:48:16 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Codes]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[UTF-8]]></category>

		<guid isPermaLink="false">http://www.miraclecodes.com/?p=144</guid>
		<description><![CDATA[Extending the PostMethod class to support UTF-8 data posting. 1 2 3 4 5 6 7 8 9 10 11 12 13 public static class UTF8PostMethod extends PostMethod &#123; public UTF8PostMethod&#40;String url&#41; &#123; super&#40;url&#41;; &#125; &#160; @Override public String getRequestCharSet&#40;&#41; &#123; return &#34;UTF-8&#34;; &#125; &#125; &#160; PostMethod method = new UTF8PostMethod&#40;&#34;http://www.google.com&#34;&#41;; method.addParameter&#40;new NameValuePair&#40;&#34;q&#34;, &#34;something with [...]]]></description>
			<content:encoded><![CDATA[<p>Extending the PostMethod class to support UTF-8 data posting.</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
11
12
13
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">      <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">class</span> UTF8PostMethod <span style="color: #000000; font-weight: bold;">extends</span> PostMethod <span style="color: #009900;">&#123;</span>
            <span style="color: #000000; font-weight: bold;">public</span> UTF8PostMethod<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> url<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                  <span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span>url<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
&nbsp;
            @Override
            <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> getRequestCharSet<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                  <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #0000ff;">&quot;UTF-8&quot;</span><span style="color: #339933;">;</span>
            <span style="color: #009900;">&#125;</span>
      <span style="color: #009900;">&#125;</span>
&nbsp;
      PostMethod method <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> UTF8PostMethod<span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;http://www.google.com&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      method.<span style="color: #006633;">addParameter</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">NameValuePair</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;q&quot;</span>, <span style="color: #0000ff;">&quot;something with special chars&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.miraclecodes.com/?feed=rss2&#038;p=144</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tooltip for GWT table</title>
		<link>http://www.miraclecodes.com/?p=129</link>
		<comments>http://www.miraclecodes.com/?p=129#comments</comments>
		<pubDate>Fri, 13 May 2011 06:41:04 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Codes]]></category>
		<category><![CDATA[GWT]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://www.miraclecodes.com/?p=129</guid>
		<description><![CDATA[If you want to add tooltip for the pure GWT table (com.google.gwt.user.cellview.client.CellTable) we can suggest the following lines; 1 2 3 4 5 6 7 8 9 Column&#60;String&#91;&#93;, SafeHtml&#62; objectNameColumn = new Column&#60;String&#91;&#93;, SafeHtml&#62;&#40;new SafeHtmlCell&#40;&#41;&#41; &#123; @Override public SafeHtml getValue&#40;String&#91;&#93; object&#41; &#123; String val = &#40;object&#91;index&#93;==null?&#34;&#34;:object&#91;index&#93;&#41;; return new SafeHtmlBuilder&#40;&#41;.appendHtmlConstant&#40;&#34;&#60;span title='&#34; + new SafeHtmlBuilder&#40;&#41;.appendEscaped&#40;val&#41;.toSafeHtml&#40;&#41;.asString&#40;&#41; + &#34;'&#62;&#34; [...]]]></description>
			<content:encoded><![CDATA[<p>If you want to add tooltip for the pure GWT table (com.google.gwt.user.cellview.client.CellTable) we can suggest the following lines;</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">	Column<span style="color: #339933;">&lt;</span>String<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span>, SafeHtml<span style="color: #339933;">&gt;</span> objectNameColumn <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Column<span style="color: #339933;">&lt;</span>String<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span>, SafeHtml<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> SafeHtmlCell<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		@Override
		<span style="color: #000000; font-weight: bold;">public</span> SafeHtml getValue<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> object<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			<span style="color: #003399;">String</span> val <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>object<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span><span style="color: #339933;">==</span><span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">?</span><span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">:</span>object<span style="color: #009900;">&#91;</span>index<span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
			<span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000000; font-weight: bold;">new</span> SafeHtmlBuilder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">appendHtmlConstant</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;&lt;span title='&quot;</span> <span style="color: #339933;">+</span> 
				<span style="color: #000000; font-weight: bold;">new</span> SafeHtmlBuilder<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">appendEscaped</span><span style="color: #009900;">&#40;</span>val<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toSafeHtml</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">asString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;'&gt;&quot;</span> <span style="color: #339933;">+</span> val <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;&lt;/span&gt;&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">toSafeHtml</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span> 
	cellTable.<span style="color: #006633;">addColumn</span><span style="color: #009900;">&#40;</span>objectNameColumn, colLabel<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.miraclecodes.com/?feed=rss2&#038;p=129</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java replaceAll the $ (Dollar sign)</title>
		<link>http://www.miraclecodes.com/?p=117</link>
		<comments>http://www.miraclecodes.com/?p=117#comments</comments>
		<pubDate>Fri, 13 May 2011 05:57:50 +0000</pubDate>
		<dc:creator>admin</dc:creator>
				<category><![CDATA[Codes]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[RegExp]]></category>

		<guid isPermaLink="false">http://www.miraclecodes.com/?p=117</guid>
		<description><![CDATA[A quick reminder! If you use Java String&#8217;s replaceAll method and not using rgexp groups, do not forget to use Matcher.quoteReplacement method. Otherwise, you will get &#8220;illegal group reference&#8221; or &#8220;&#8221;String index out of range&#8221; error when the $ sign occurs in the replacement value (2nd parameter). Example: 1 2 3 4 5 6 7 [...]]]></description>
			<content:encoded><![CDATA[<p>A quick reminder!</p>
<p>If you use Java String&#8217;s replaceAll method and not using rgexp groups, do not forget to use Matcher.quoteReplacement method.<br />
Otherwise, you will get &#8220;illegal group reference&#8221; or &#8220;&#8221;String index out of range&#8221; error when the $ sign occurs in the replacement value (2nd parameter).</p>
<p>Example:</p>

<div class="wp_syntax"><table><tr><td class="line_numbers"><pre>1
2
3
4
5
6
7
8
9
10
</pre></td><td class="code"><pre class="java" style="font-family:monospace;">	<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;replace the dollar sign&quot;</span>.<span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;dollar sign&quot;</span>, <span style="color: #0000ff;">&quot;$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	<span style="color: #666666; font-style: italic;">//Error: &quot;String index out of range: 1&quot;</span>
	<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;replace the dollar sign&quot;</span>.<span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;dollar sign&quot;</span>, <span style="color: #0000ff;">&quot;$ sign&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//Error: &quot;Illegal group reference&quot;</span>
	<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;replace the dollar sign&quot;</span>.<span style="color: #006633;">replaceAll</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;dollar sign&quot;</span>, Matcher.<span style="color: #006633;">quoteReplacement</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #666666; font-style: italic;">//&quot;replace the $&quot;</span>
&nbsp;
	<span style="color: #666666; font-style: italic;">// or you always have the comfortable StringUtils.replace option</span>
	<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>StringUtils.<span style="color: #006633;">replace</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;replace the dollar sign&quot;</span>, <span style="color: #0000ff;">&quot;dollar sign&quot;</span>, <span style="color: #0000ff;">&quot;$&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> 
	<span style="color: #666666; font-style: italic;">//&quot;replace the $&quot;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://www.miraclecodes.com/?feed=rss2&#038;p=117</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

