<?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>Silveira Neto &#187; code</title>
	<atom:link href="http://silveiraneto.net/tag/code/feed/" rel="self" type="application/rss+xml" />
	<link>http://silveiraneto.net</link>
	<description></description>
	<lastBuildDate>Fri, 09 Mar 2012 04:13:27 +0000</lastBuildDate>
	<language>pt-br</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>OpenCV: adding two images</title>
		<link>http://silveiraneto.net/2009/12/08/opencv-adding-two-images/</link>
		<comments>http://silveiraneto.net/2009/12/08/opencv-adding-two-images/#comments</comments>
		<pubDate>Tue, 08 Dec 2009 04:55:05 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Computer Vision]]></category>
		<category><![CDATA[cvadd]]></category>
		<category><![CDATA[opencv]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[surfer]]></category>
		<category><![CDATA[universe]]></category>
		<category><![CDATA[wikimedia]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=3013</guid>
		<description><![CDATA[<a href="http://silveiraneto.net/2009/12/08/opencv-adding-two-images/" title="OpenCV: adding two images"></a>This is a very simple example of how to open two images and display them added. I got two pictures at project Commons from Wikimedia that were highlighted on Featured Pictures. I did a crop on both to have the &#8230;<p class="read-more"><a href="http://silveiraneto.net/2009/12/08/opencv-adding-two-images/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://silveiraneto.net/2009/12/08/opencv-adding-two-images/" title="OpenCV: adding two images"></a><p>This is a very simple example of how to open two images and display them added.</p>
<p>I got two pictures at project <a href="http://commons.wikimedia.org">Commons</a> from <a href="http://wikimedia.org">Wikimedia</a> <span id="result_box"><span style="background-color: #ffffff;" title="Duas imagens que ganharam destaque.">that were highlighted on Featured Pictures</span></span>. I did a crop on both to have the same size, as I&#8217;m trying to make this example as simple as possible.</p>
<p>The <a title="Wikipedia" href="http://commons.wikimedia.org/wiki/File:Guisard_-_Milky_Way.jpg">first one is a photo of our Milky Way</a>, taken at <a title="Wikipedia" href="http://en.wikipedia.org/wiki/Paranal_Observatory">Paranal Observatory</a> by Stéphane Guisard.</p>
<p style="text-align: center;"><img class="size-full wp-image-3014 aligncenter" title="milkyway sky Stéphane Guisard Paranal" src="http://silveiraneto.net/wp-content/uploads/2009/12/milkyway.jpg" alt="milkyway " width="500" height="400" /></p>
<p>The second one is a <a href="http://commons.wikimedia.org/wiki/File:California_surfer_inside_wave.jpg">California surfer inside wave</a>, taken by <a href="http://home.comcast.net/~milazinkova/Fogshadow.html">Mila Zinkova</a>.</p>
<p style="text-align: center;"><img class="size-full wp-image-3015 aligncenter" title="surfer" src="http://silveiraneto.net/wp-content/uploads/2009/12/surfer.jpg" alt="surfer" width="500" height="400" /></p>
<p>In this simple <a title="OpenCV" href="http://sourceforge.net/projects/opencvlibrary/">OpenCV</a> code below, we open the images, create a new one to display the result and use cvAdd to add them. We do not save the result or handle more than the ordinary case of two images with the same size.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #339933;">#include &lt;stdio.h&gt;</span>
<span style="color: #339933;">#include &lt;cv.h&gt;</span>
<span style="color: #339933;">#include &lt;highgui.h&gt;</span>
&nbsp;
<span style="color: #993333;">int</span> main<span style="color: #009900;">&#40;</span> <span style="color: #993333;">int</span> argc<span style="color: #339933;">,</span> <span style="color: #993333;">char</span> <span style="color: #339933;">**</span>argv <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    IplImage <span style="color: #339933;">*</span>surfer<span style="color: #339933;">,</span> <span style="color: #339933;">*</span>milkyway<span style="color: #339933;">,</span> <span style="color: #339933;">*</span>result<span style="color: #339933;">;</span>
    <span style="color: #993333;">int</span> key <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
    CvSize size<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* load images, check, get size (both should have the same) */</span>
    surfer <span style="color: #339933;">=</span> cvLoadImage<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;surfer.jpg&quot;</span><span style="color: #339933;">,</span> CV_LOAD_IMAGE_COLOR<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    milkyway <span style="color: #339933;">=</span> cvLoadImage<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;milkyway.jpg&quot;</span><span style="color: #339933;">,</span> CV_LOAD_IMAGE_COLOR<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>surfer<span style="color: #009900;">&#41;</span><span style="color: #339933;">||</span><span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>milkyway<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000066;">printf</span><span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;Could not open one or more images.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        exit <span style="color: #339933;">-</span><span style="color: #0000dd;">1</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    size <span style="color: #339933;">=</span> cvGetSize<span style="color: #009900;">&#40;</span>surfer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* create a empty image, same size, depth and channels of others */</span>
    result <span style="color: #339933;">=</span> cvCreateImage<span style="color: #009900;">&#40;</span>size<span style="color: #339933;">,</span> surfer<span style="color: #339933;">-&gt;</span>depth<span style="color: #339933;">,</span> surfer<span style="color: #339933;">-&gt;</span>nChannels<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    cvZero<span style="color: #009900;">&#40;</span>result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* result = surfer + milkyway (NULL mask)*/</span>
    cvAdd<span style="color: #009900;">&#40;</span>surfer<span style="color: #339933;">,</span> milkyway<span style="color: #339933;">,</span> result<span style="color: #339933;">,</span> NULL<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* create a window, display the result, wait for a key */</span>
    cvNamedWindow<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;example&quot;</span><span style="color: #339933;">,</span> CV_WINDOW_AUTOSIZE<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    cvShowImage<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;example&quot;</span><span style="color: #339933;">,</span> result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    cvWaitKey<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #808080; font-style: italic;">/* free memory and get out */</span>
    cvDestroyWindow<span style="color: #009900;">&#40;</span><span style="color: #ff0000;">&quot;example&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    cvReleaseImage<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>surfer<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    cvReleaseImage<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>milkyway<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    cvReleaseImage<span style="color: #009900;">&#40;</span><span style="color: #339933;">&amp;</span>result<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">return</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #808080; font-style: italic;">/* gcc add.c -o add `pkg-config opencv --libs --cflags` */</span></pre></div></div>

<p>Compile it (on a well configured OpenCV development environment) and run it:</p>
<blockquote><p>gcc add.c -o add `pkg-config opencv &#8211;libs &#8211;cflags`<br />
./add</p></blockquote>
<p>The result got pretty cool, a milky way surfer.</p>
<p style="text-align: center;"><img class="size-full wp-image-3016 aligncenter" title="surfer in the milk way" src="http://silveiraneto.net/wp-content/uploads/2009/12/result.jpg" alt="surfer in the milk way" width="500" height="400" /></p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2009/12/08/opencv-adding-two-images/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>BumbaBot-1</title>
		<link>http://silveiraneto.net/2009/03/16/bumbabot-1/</link>
		<comments>http://silveiraneto.net/2009/03/16/bumbabot-1/#comments</comments>
		<pubDate>Mon, 16 Mar 2009 03:43:42 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[Arduino]]></category>
		<category><![CDATA[boi bumbá]]></category>
		<category><![CDATA[bumba meu boi]]></category>
		<category><![CDATA[bumbabot-1]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[High-Current Darlington Transistor Arrays]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Open Hardware]]></category>
		<category><![CDATA[Open Source]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[roboitcs]]></category>
		<category><![CDATA[tutorial]]></category>
		<category><![CDATA[ULN2003A]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=2384</guid>
		<description><![CDATA[ <p class="read-more"><a href="http://silveiraneto.net/2009/03/16/bumbabot-1/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://silveiraneto.net/2009/03/16/bumbabot-1/" title="BumbaBot-1"></a><p>I got a simple motor from a broken domestic printer. It&#8217;s a <a title="Mitsumi product" href="http://www.mitsumi.co.jp/Catalog/compo/motor/m35sp9_e.html">Mitsumi m355P-9T stepping motor</a>. Any other common stepping motor should fits. You can find one in printers, multifunction machines, copy machines, FAX, and such.</p>
<p style="text-align: center;"><a title="bumbabot v01 by Silveira Neto, on Flickr" href="http://www.flickr.com/photos/silveiraneto/3358845802/"><img class="aligncenter" src="http://farm4.static.flickr.com/3460/3358845802_286e74ee01.jpg" alt="bumbabot v01" width="500" height="375" /></a></p>
<p>With a flexible cap of water bottle with a hole we make a connection between the motor axis and other objects.</p>
<p style="text-align: center;"><a title="bumbabot v01 by Silveira Neto, on Flickr" href="http://www.flickr.com/photos/silveiraneto/3358029549/"><img class="aligncenter" src="http://farm4.static.flickr.com/3571/3358029549_0b9680180a.jpg" alt="bumbabot v01" width="500" height="375" /></a></p>
<p style="text-align: center;"><a title="bumbabot v01 by Silveira Neto, on Flickr" href="http://www.flickr.com/photos/silveiraneto/3358031295/"><img class="aligncenter" src="http://farm4.static.flickr.com/3582/3358031295_fb8ed598cc.jpg" alt="bumbabot v01" width="500" height="375" /></a></p>
<p>With super glue I attached to the cap a little handcraft clay ox statue.</p>
<p style="text-align: center;"><a title="bumbabot v01 by Silveira Neto, on Flickr" href="http://www.flickr.com/photos/silveiraneto/3358032255/"><img class="aligncenter" src="http://farm4.static.flickr.com/3612/3358032255_3686d7e295.jpg" alt="bumbabot v01" width="500" height="375" /></a></p>
<p>It&#8217;s a representation from a Brazilian folkloric character <a title="Wikipedia, english" href="http://en.wikipedia.org/wiki/Bumba_Meu_Boi">Boi Bumbá</a>. In some traditional parties in Brazil, someone dress a structure-costume and dances in circular patterns interacting with the public.</p>
<p style="text-align: center;"><a href="http://www.flickr.com/photos/canoafurada/776513346/"><img class="size-full wp-image-2392 aligncenter" title="776513346_c31db6843b_m" src="http://silveiraneto.net/wp-content/uploads/2009/03/776513346_c31db6843b_m.jpg" alt="776513346_c31db6843b_m" width="198" height="240" /></a></p>
<p style="text-align: center;"><a href="http://www.flickr.com/photos/canoafurada/2246467684/"><img class="size-full wp-image-2393 aligncenter" title="2246467684_49164d3397_m" src="http://silveiraneto.net/wp-content/uploads/2009/03/2246467684_49164d3397_m.jpg" alt="2246467684_49164d3397_m" width="240" height="160" /></a><br />
<small>Photos by <a href="http://www.flickr.com/people/canoafurada/">Marcus Guimarães</a>.</small></p>
<p>Controlling a stepper motor is not difficult.  There&#8217;s a good documentation on how to that on the <a title="Arduino Docs" href="http://www.arduino.cc/en/Tutorial/StepperUnipolar">Arduino Stepper Motor Tutorial</a>. Basically it&#8217;s about sending a logical signal for each coil in a circular order (that is also called full step).</p>
<p style="text-align: center;"><img class="size-full wp-image-2403 aligncenter" title="full step" src="http://silveiraneto.net/wp-content/uploads/2009/03/animacompleto1.gif" alt="full step" width="97" height="97" /></p>
<p style="text-align: center;"><small>Animation from <a href="http://www.rogercom.com/pparalela/IntroMotorPasso.htm">rogercom.com</a>.</small></p>
<p style="text-align: center;"><img class="size-full wp-image-2400 aligncenter" title="stepper motor diagram" src="http://silveiraneto.net/wp-content/uploads/2009/03/stepper_motor_diagram.png" alt="stepper motor diagram" width="348" height="265" /></p>
<p>You&#8217;ll probably also use a driver chip ULN2003A or similar to give to the motor more current than your Arduino can provide and also for protecting it from a power comming back from the motor. It&#8217;s a very easy find this tiny chip on electronics or automotive  stores or also from broken printers where you probably found your stepped motor.</p>
<p style="text-align: center;"><img class="size-full wp-image-2404 aligncenter" title="Arduino Stepper Motor UNL2003A" src="http://silveiraneto.net/wp-content/uploads/2009/03/arduino_stepper_motor_uln2003a.jpg" alt="Arduino Stepper Motor UNL2003A" width="400" height="514" /></p>
<p>With a simple program you can already controlling your motor.</p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Simple stepped motor spin</span>
<span style="color: #666666; font-style: italic;">// by Silveira Neto, 2009, under GPLv3 license</span>
<span style="color: #666666; font-style: italic;">// http://silveiraneto.net/2009/03/16/bumbabot-1/</span>
<span style="color: #993333;">int</span> coil1 <span style="color: #339933;">=</span> <span style="color: #0000dd;">8</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> coil2 <span style="color: #339933;">=</span> <span style="color: #0000dd;">9</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> coil3 <span style="color: #339933;">=</span> <span style="color: #0000dd;">10</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> coil4 <span style="color: #339933;">=</span> <span style="color: #0000dd;">11</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> step <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> interval <span style="color: #339933;">=</span> <span style="color: #0000dd;">100</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  pinMode<span style="color: #009900;">&#40;</span>coil1<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>coil2<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>coil3<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>coil4<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>coil1<span style="color: #339933;">,</span> step<span style="color: #339933;">==</span><span style="color: #0000dd;">0</span><span style="color: #339933;">?</span>HIGH<span style="color: #339933;">:</span>LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>coil2<span style="color: #339933;">,</span> step<span style="color: #339933;">==</span><span style="color: #0000dd;">1</span><span style="color: #339933;">?</span>HIGH<span style="color: #339933;">:</span>LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>coil3<span style="color: #339933;">,</span> step<span style="color: #339933;">==</span><span style="color: #0000dd;">2</span><span style="color: #339933;">?</span>HIGH<span style="color: #339933;">:</span>LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>coil4<span style="color: #339933;">,</span> step<span style="color: #339933;">==</span><span style="color: #0000dd;">3</span><span style="color: #339933;">?</span>HIGH<span style="color: #339933;">:</span>LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  delay<span style="color: #009900;">&#40;</span>interval<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  step <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>step<span style="color: #339933;">+</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">%</span><span style="color:#800080;">4</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p style="text-align: center;"><object width="425" height="344" data="http://www.youtube.com/v/roq9z3tpEhI&amp;hl=pt-br&amp;fs=1" type="application/x-shockwave-flash"><param name="allowFullScreen" value="true" /><param name="allowscriptaccess" value="always" /><param name="src" value="http://www.youtube.com/v/roq9z3tpEhI&amp;hl=pt-br&amp;fs=1" /><param name="allowfullscreen" value="true" /></object><br />
Writing a little bit more generally code we can create function to step forward and step backward.</p>
<p>My motor needs 48 steps to run a complete turn. So 360º/48 steps give us 7,5º per step. Arduino has a simple <a title="Arduino Reference" href="http://www.arduino.cc/en/Reference/Stepper">Stepper Motor Library</a> but it doesn&#8217;t worked with me and it&#8217;s also oriented to steps and I&#8217;d need something oriented to angles instead. So I wrote some routines to do that.</p>
<p>For this first version of BumbaBot I mapped angles with letters to easy the communication between the programs.</p>
<p style="text-align: center;"><img class="alignnone size-full wp-image-2411" title="motor angle step control" src="http://silveiraneto.net/wp-content/uploads/2009/03/motor_angle_control_map.png" alt="motor angle step control" width="300" height="236" /></p>
<p>Notice that <strong>it&#8217;s not the final version and there&#8217;s still some bugs!</strong></p>

<div class="wp_syntax"><div class="code"><pre class="c" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">// Stepped motor control by letters</span>
<span style="color: #666666; font-style: italic;">// by Silveira Neto, 2009, under GPLv3 license</span>
<span style="color: #666666; font-style: italic;">// http://silveiraneto.net/2009/03/16/bumbabot-1/</span>
&nbsp;
<span style="color: #993333;">int</span> coil1 <span style="color: #339933;">=</span> <span style="color: #0000dd;">8</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> coil2 <span style="color: #339933;">=</span> <span style="color: #0000dd;">9</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> coil3 <span style="color: #339933;">=</span> <span style="color: #0000dd;">10</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> coil4 <span style="color: #339933;">=</span> <span style="color: #0000dd;">11</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">int</span> delayTime <span style="color: #339933;">=</span> <span style="color: #0000dd;">50</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> steps <span style="color: #339933;">=</span> <span style="color: #0000dd;">48</span><span style="color: #339933;">;</span>
<span style="color: #993333;">int</span> step_counter <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #993333;">void</span> setup<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  pinMode<span style="color: #009900;">&#40;</span>coil1<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>coil2<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>coil3<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  pinMode<span style="color: #009900;">&#40;</span>coil4<span style="color: #339933;">,</span> OUTPUT<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  Serial.<span style="color: #202020;">begin</span><span style="color: #009900;">&#40;</span><span style="color: #0000dd;">9600</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// tells motor to move a certain angle</span>
<span style="color: #993333;">void</span> moveAngle<span style="color: #009900;">&#40;</span><span style="color: #993333;">float</span> angle<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #993333;">int</span> i<span style="color: #339933;">;</span>
  <span style="color: #993333;">int</span> howmanysteps <span style="color: #339933;">=</span> angle<span style="color: #339933;">/</span>stepAngle<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>howmanysteps<span style="color: #339933;">&lt;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    howmanysteps <span style="color: #339933;">=</span> <span style="color: #339933;">-</span> howmanysteps<span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>angle<span style="color: #339933;">&gt;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i <span style="color: #339933;">=</span> <span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>howmanysteps<span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      step<span style="color: #009900;">&#40;</span>i<span style="color: #339933;">%</span><span style="color:#800080;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      delay<span style="color: #009900;">&#40;</span>delayTime<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: #b1b100;">else</span><span style="color: #009900;">&#123;</span>
    <span style="color: #b1b100;">for</span><span style="color: #009900;">&#40;</span>i<span style="color: #339933;">=</span><span style="color: #0000dd;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span>howmanysteps<span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
      backstep<span style="color: #009900;">&#40;</span>i<span style="color: #339933;">%</span><span style="color:#800080;">4</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
      delay<span style="color: #009900;">&#40;</span>delayTime<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>
&nbsp;
<span style="color: #666666; font-style: italic;">// tells motor to move to a certain angle</span>
<span style="color: #993333;">void</span> moveToAngle<span style="color: #009900;">&#40;</span><span style="color: #993333;">float</span> angle<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  moveAngle<span style="color: #009900;">&#40;</span>angle<span style="color: #339933;">-</span>actualAngle<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// actual stepper motor angle</span>
<span style="color: #993333;">float</span> actualAngle<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">return</span> step_counter<span style="color: #339933;">*</span>stepAngle<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// angle made by each step</span>
<span style="color: #993333;">float</span> stepAngle<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  <span style="color: #b1b100;">return</span> <span style="color:#800080;">360.0</span><span style="color: #339933;">/</span>steps<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// backward step</span>
<span style="color: #993333;">void</span> backstep<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> coil<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>coil1<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>coil<span style="color: #339933;">==</span><span style="color: #0000dd;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span>HIGH<span style="color: #339933;">:</span>LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>coil2<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>coil<span style="color: #339933;">==</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span>HIGH<span style="color: #339933;">:</span>LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>coil3<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>coil<span style="color: #339933;">==</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span>HIGH<span style="color: #339933;">:</span>LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>coil4<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>coil<span style="color: #339933;">==</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span>HIGH<span style="color: #339933;">:</span>LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  step_counter<span style="color: #339933;">--;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">// forward step</span>
<span style="color: #993333;">void</span> step<span style="color: #009900;">&#40;</span><span style="color: #993333;">int</span> coil<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>coil1<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>coil<span style="color: #339933;">==</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span>HIGH<span style="color: #339933;">:</span>LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>coil2<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>coil<span style="color: #339933;">==</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span>HIGH<span style="color: #339933;">:</span>LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>coil3<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>coil<span style="color: #339933;">==</span><span style="color: #0000dd;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span>HIGH<span style="color: #339933;">:</span>LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  digitalWrite<span style="color: #009900;">&#40;</span>coil4<span style="color: #339933;">,</span> <span style="color: #009900;">&#40;</span>coil<span style="color: #339933;">==</span><span style="color: #0000dd;">3</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">?</span>HIGH<span style="color: #339933;">:</span>LOW<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  step_counter<span style="color: #339933;">++;</span>
<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #993333;">void</span> loop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
  byte val<span style="color: #339933;">;</span>
  <span style="color: #b1b100;">if</span><span style="color: #009900;">&#40;</span>Serial.<span style="color: #202020;">available</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    val <span style="color: #339933;">=</span> Serial.<span style="color: #202020;">read</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #b1b100;">switch</span> <span style="color: #009900;">&#40;</span>val<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
      <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'A'</span><span style="color: #339933;">:</span> moveToAngle<span style="color: #009900;">&#40;</span>  <span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'B'</span><span style="color: #339933;">:</span> moveToAngle<span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">45</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'C'</span><span style="color: #339933;">:</span> moveToAngle<span style="color: #009900;">&#40;</span> <span style="color: #0000dd;">90</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'D'</span><span style="color: #339933;">:</span> moveToAngle<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">135</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'E'</span><span style="color: #339933;">:</span> moveToAngle<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">180</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'F'</span><span style="color: #339933;">:</span> moveToAngle<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">225</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'G'</span><span style="color: #339933;">:</span> moveToAngle<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">270</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'H'</span><span style="color: #339933;">:</span> moveToAngle<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">315</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'I'</span><span style="color: #339933;">:</span> backstep<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> backstep<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
      <span style="color: #b1b100;">case</span> <span style="color: #ff0000;">'J'</span><span style="color: #339933;">:</span> step<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> step<span style="color: #009900;">&#40;</span><span style="color: #0000dd;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>   <span style="color: #000000; font-weight: bold;">break</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
    Serial.<span style="color: #202020;">print</span><span style="color: #009900;">&#40;</span>val<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In another post I wrote <a title="Arduino and Java" href="http://silveiraneto.net/2009/03/01/arduino-and-java/">how create a Java program to talk with Arduino</a>. We&#8217;ll use this to send messages to Arduino to it moves. </p>
<p style="text-align: center;"><img src="http://silveiraneto.net/wp-content/uploads/2009/03/captura_de_tela-bumba01-netbeans-ide-65-500x283.png" alt="captura_de_tela-bumba01-netbeans-ide-65" title="captura_de_tela-bumba01-netbeans-ide-65" width="500" height="283" class="alignnone size-medium wp-image-2416" /></p>
<p>[put final video here]</p>
<p><strong>To be continued&#8230; </strong>:)</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2009/03/16/bumbabot-1/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Example of Unix commands implemented in Java</title>
		<link>http://silveiraneto.net/2008/10/07/example-of-unix-commands-implemented-in-java/</link>
		<comments>http://silveiraneto.net/2008/10/07/example-of-unix-commands-implemented-in-java/#comments</comments>
		<pubDate>Tue, 07 Oct 2008 23:42:31 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[cat]]></category>
		<category><![CDATA[cd]]></category>
		<category><![CDATA[cli]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[ls]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[pwd]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=1364</guid>
		<description><![CDATA[<a href="http://silveiraneto.net/2008/10/07/example-of-unix-commands-implemented-in-java/" title="Example of Unix commands implemented in Java"></a>I created some illustrative and simple implementations of common Unix commands. For those who are familiar with Unix-like systems them make easier to understand Java. For those who are familiar with Java them make easier to understand Unix-like systems. :-) &#8230;<p class="read-more"><a href="http://silveiraneto.net/2008/10/07/example-of-unix-commands-implemented-in-java/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://silveiraneto.net/2008/10/07/example-of-unix-commands-implemented-in-java/" title="Example of Unix commands implemented in Java"></a><p>I created some illustrative and simple implementations of common Unix commands. For those who are familiar with Unix-like systems them make easier to understand Java. For those who are familiar with Java them make easier to understand Unix-like systems. :-)</p>
<p><strong>1. PWD</strong></p>
<p><strong></strong></p>
<p>The first one is <a title="Wikipedia, english" href="http://en.wikipedia.org/wiki/Pwd">pwd</a> that show the current working directory.</p>

<div class="wp_syntax"><div 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;">class</span> Jpwd <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">String</span> pwd <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;user.dir&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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>pwd<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>Running this at /home/silveira directory gives us as output:</p>
<blockquote><p>$ java Jpwd</p>
<p>/home/silveira</p></blockquote>
<p><strong>1. CAT</strong></p>
<p>The command <a title="Wikipedia, english" href="http://en.wikipedia.org/wiki/Cat_(Unix)">cat</a> is usually utilized for displaying files.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.BufferedReader</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.FileNotFoundException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.FileReader</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.IOException</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Jcat <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<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>args.<span style="color: #006633;">length</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">1</span><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: #003399;">FileReader</span> fileReader <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileReader</span><span style="color: #009900;">&#40;</span>args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #003399;">BufferedReader</span> in <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedReader</span><span style="color: #009900;">&#40;</span>fileReader<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                <span style="color: #003399;">String</span> line<span style="color: #339933;">;</span>
                <span style="color: #000000; font-weight: bold;">while</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>line <span style="color: #339933;">=</span> in.<span style="color: #006633;">readLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><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>
                    <span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>line<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: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">FileNotFoundException</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</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>args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;, file not found.&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;">catch</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">IOException</span> ex<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</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>args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;, input/output error.&quot;</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;">&#125;</span></pre></div></div>

<blockquote><p>$ java Jcat /etc/timezone</p>
<p>America/Fortaleza</p></blockquote>
<p><strong>3. LS</strong></p>
<p><strong></strong></p>
<p>The command ls is to list files. The File API (<a href="http://java.sun.com/j2se/1.4.2/docs/api/java/io/File.html">java.io.File</a>) is very flexible and portable, but in this example I want just list files and directories of the current directory.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.File</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Jls <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">File</span> dir <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">System</span>.<span style="color: #006633;">getProperty</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;user.dir&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #003399;">String</span> childs<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">=</span> dir.<span style="color: #006633;">list</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;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> child<span style="color: #339933;">:</span> childs<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</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>child<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></pre></div></div>

<p>Usage:</p>
<blockquote><p>$ java Jpwd</p>
<p>/home/silveira/example</p>
<p>$ java Jls</p>
<p>directoryA</p>
<p>fileA</p>
<p>.somefile</p></blockquote>
<p><del datetime="2008-10-09T15:50:53+00:00"><strong>4. CD</strong></p>
<p>The <a href="http://en.wikipedia.org/wiki/Cd_(command)">cd</a> command changes the current working directory.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.File</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Jcd <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<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>args.<span style="color: #006633;">length</span><span style="color: #339933;">==</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            <span style="color: #003399;">File</span> dir <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</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>dir.<span style="color: #006633;">isDirectory</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;">true</span><span style="color: #009900;">&#41;</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: #0000ff;">&quot;user.dir&quot;</span>, dir.<span style="color: #006633;">getAbsolutePath</span><span style="color: #009900;">&#40;</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;">else</span> <span style="color: #009900;">&#123;</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>args<span style="color: #009900;">&#91;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#93;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;is not a directory.&quot;</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;">&#125;</span></pre></div></div>

<p>Usage:</p>
<blockquote><p>$ java Jpwd<br />
/home/silveira<br />
$ java Jcd /tmp<br />
$ java Jpwd<br />
/tmp</p></blockquote>
<p></del></p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/10/07/example-of-unix-commands-implemented-in-java/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Java Calendar Examples</title>
		<link>http://silveiraneto.net/2008/07/01/java-calendar-examples/</link>
		<comments>http://silveiraneto.net/2008/07/01/java-calendar-examples/#comments</comments>
		<pubDate>Tue, 01 Jul 2008 14:15:05 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[Calendar]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[java.util.Calendar]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=952</guid>
		<description><![CDATA[<a href="http://silveiraneto.net/2008/07/01/java-calendar-examples/" title="Java Calendar Examples"></a>import java.util.Calendar; &#160; public class Main &#123; public static void main&#40;String&#91;&#93; args&#41; &#123; Calendar today = Calendar.getInstance&#40;&#41;; System.out.println&#40;&#34;Today is &#34; + today.getTime&#40;&#41;&#41;; &#125; &#125; In this simplest example of Calendar, the output would be Today is : Tue Jul 01 &#8230;<p class="read-more"><a href="http://silveiraneto.net/2008/07/01/java-calendar-examples/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://silveiraneto.net/2008/07/01/java-calendar-examples/" title="Java Calendar Examples"></a>
<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Calendar</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">Calendar</span> today <span style="color: #339933;">=</span> <span style="color: #003399;">Calendar</span>.<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: #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;Today is  &quot;</span> <span style="color: #339933;">+</span> today.<span style="color: #006633;">getTime</span><span style="color: #009900;">&#40;</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: #009900;">&#125;</span></pre></div></div>

<p>In this simplest example of <a href="http://java.sun.com/j2se/1.4.2/docs/api/java/util/Calendar.html">Calendar</a>, the output would be</p>
<blockquote><p>Today is : Tue Jul 01 10:56:14 BRT 2008</p></blockquote>
<p>In the next example how to get information about the day inside the year, month and week.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Calendar</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">Calendar</span> today <span style="color: #339933;">=</span> <span style="color: #003399;">Calendar</span>.<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: #000066; font-weight: bold;">int</span> dof <span style="color: #339933;">=</span> today.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Calendar</span>.<span style="color: #006633;">DAY_OF_YEAR</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> dom <span style="color: #339933;">=</span> today.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Calendar</span>.<span style="color: #006633;">DAY_OF_MONTH</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #000066; font-weight: bold;">int</span> dow <span style="color: #339933;">=</span> today.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Calendar</span>.<span style="color: #006633;">DAY_OF_WEEK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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;Today is the &quot;</span> <span style="color: #339933;">+</span> dof <span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;º day in this year,&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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;the &quot;</span> <span style="color: #339933;">+</span> dom <span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;º day in this month&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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;and the &quot;</span> <span style="color: #339933;">+</span> dow <span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;º day in this week.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>The output could be</p>
<blockquote><p>Today is the 183º day in this year,<br />
the 1º day in this month<br />
and the 3º day in this week.</p></blockquote>
<p>The next example is about how to add (and subtract) a duration from a Calendar.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Calendar</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> Main <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        <span style="color: #003399;">Calendar</span> today <span style="color: #339933;">=</span> <span style="color: #003399;">Calendar</span>.<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: #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;Today is &quot;</span> <span style="color: #339933;">+</span> today.<span style="color: #006633;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003399;">Calendar</span> yesterday <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Calendar</span><span style="color: #009900;">&#41;</span>today.<span style="color: #006633;">clone</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        yesterday.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Calendar</span>.<span style="color: #006633;">DATE</span>, <span style="color: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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;Yesterday was &quot;</span> <span style="color: #339933;">+</span> yesterday.<span style="color: #006633;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        <span style="color: #003399;">Calendar</span> tomorow <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #003399;">Calendar</span><span style="color: #009900;">&#41;</span>today.<span style="color: #006633;">clone</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        tomorow.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Calendar</span>.<span style="color: #006633;">DATE</span>, <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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;Tomorow will be &quot;</span> <span style="color: #339933;">+</span> tomorow.<span style="color: #006633;">getTime</span><span style="color: #009900;">&#40;</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: #009900;">&#125;</span></pre></div></div>

<p>A typical output would be</p>
<blockquote><p>Today is Tue Jul 01 10:44:18 BRT 2008<br />
Yesterday was Mon Jun 30 10:44:18 BRT 2008<br />
Tomorow will be Wed Jul 02 10:44:18 BRT 2008</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/07/01/java-calendar-examples/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Integer.MAX_VALUE and Integer.MIN_VALUE</title>
		<link>http://silveiraneto.net/2008/04/11/integermax_value-and-integermin_value/</link>
		<comments>http://silveiraneto.net/2008/04/11/integermax_value-and-integermin_value/#comments</comments>
		<pubDate>Sat, 12 Apr 2008 01:09:52 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[example]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[jeg]]></category>
		<category><![CDATA[MAX_VALUE]]></category>
		<category><![CDATA[MIN_VALUE]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/?p=829</guid>
		<description><![CDATA[<a href="http://silveiraneto.net/2008/04/11/integermax_value-and-integermin_value/" title="Integer.MAX_VALUE and Integer.MIN_VALUE"></a>You should know that variable values are cyclic in Java. public class Test&#123; public static void main&#40;String args&#91;&#93;&#41;&#123; System.out.println&#40;Integer.MAX_VALUE&#41;; System.out.println&#40;Integer.MIN_VALUE&#41;; int x = Integer.MAX_VALUE + 1; System.out.println&#40;x&#41;; &#125; &#125; This produces: 2147483647 -2147483648 -2147483648]]></description>
			<content:encoded><![CDATA[<a href="http://silveiraneto.net/2008/04/11/integermax_value-and-integermin_value/" title="Integer.MAX_VALUE and Integer.MIN_VALUE"></a><p>You should know that variable values are cyclic in Java.</p>

<div class="wp_syntax"><div 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;">class</span> Test<span style="color: #009900;">&#123;</span>
  <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</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: #003399;">Integer</span>.<span style="color: #006633;">MAX_VALUE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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: #003399;">Integer</span>.<span style="color: #006633;">MIN_VALUE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
     <span style="color: #000066; font-weight: bold;">int</span> x <span style="color: #339933;">=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">MAX_VALUE</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</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>x<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
  <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>This produces:</p>
<blockquote><p>2147483647<br />
-2147483648<br />
-2147483648</p></blockquote>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/04/11/integermax_value-and-integermin_value/feed/</wfw:commentRss>
		<slash:comments>7</slash:comments>
		</item>
		<item>
		<title>NumberFormatException Example</title>
		<link>http://silveiraneto.net/2008/03/21/numberformatexception-example/</link>
		<comments>http://silveiraneto.net/2008/03/21/numberformatexception-example/#comments</comments>
		<pubDate>Sat, 22 Mar 2008 02:42:20 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Exceptions]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[NumberFormatException]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[tutorial]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/2008/03/21/numberformatexception-example/</guid>
		<description><![CDATA[<a href="http://silveiraneto.net/2008/03/21/numberformatexception-example/" title="NumberFormatException Example"></a>NumberFormatException: Thrown to indicate that the application has attempted to convert a string to one of the numeric types, but that the string does not have the appropriate format. An simple example: public class SummationExample &#123; public static void main&#40;String &#8230;<p class="read-more"><a href="http://silveiraneto.net/2008/03/21/numberformatexception-example/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://silveiraneto.net/2008/03/21/numberformatexception-example/" title="NumberFormatException Example"></a><blockquote><p><em>NumberFormatException</em>: Thrown to indicate that the application has attempted to convert a string to one of the numeric types, but that the string does not have the appropriate format.</p></blockquote>
<p>An simple example:</p>

<div class="wp_syntax"><div 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;">class</span> SummationExample <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">int</span> sum <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> arg<span style="color: #339933;">:</span> args<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</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;+&quot;</span> <span style="color: #339933;">+</span> arg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            sum <span style="color: #339933;">+=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>arg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
        <span style="color: #009900;">&#125;</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;= &quot;</span> <span style="color: #339933;">+</span> sum<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<blockquote><p>$ javac SummationExample.java<br />
$ java SummationExample 1 2 3 4 5<br />
+1<br />
+2<br />
+3<br />
+4<br />
+5<br />
= 15
</p></blockquote>
<p>but </p>
<blockquote><p>
$ java SummationExample 1 2 3 4 five<br />
+1<br />
+2<br />
+3<br />
+4<br />
+five<br />
Exception in thread &#8220;main&#8221; java.lang.NumberFormatException: For input string: &#8220;five&#8221;<br />
        at java.lang.NumberFormatException.forInputString(NumberFormatException.java:48)<br />
        at java.lang.Integer.parseInt(Integer.java:447)<br />
        at java.lang.Integer.parseInt(Integer.java:497)<br />
        at SummationExample.main(SummationExample.java:6)
</p></blockquote>
<p>So</p>

<div class="wp_syntax"><div 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;">class</span> SummationExample <span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        <span style="color: #000066; font-weight: bold;">int</span> sum <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
        <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> arg<span style="color: #339933;">:</span> args<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>
                sum <span style="color: #339933;">+=</span> <span style="color: #003399;">Integer</span>.<span style="color: #006633;">parseInt</span><span style="color: #009900;">&#40;</span>arg<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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;+&quot;</span> <span style="color: #339933;">+</span> arg<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;">NumberFormatException</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                <span style="color: #666666; font-style: italic;">// nothing</span>
            <span style="color: #009900;">&#125;</span>
        <span style="color: #009900;">&#125;</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;= &quot;</span> <span style="color: #339933;">+</span> sum<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>now </p>
<blockquote><p>$ javac BetterSummationExample.java<br />
$ java BetterSummationExample 1 2 3 4 5<br />
+1<br />
+2<br />
+3<br />
+4<br />
+5<br />
= 15</p></blockquote>
<p>and also </p>
<blockquote><p>$ java BetterSummationExample 1 2 3 4 five<br />
+1<br />
+2<br />
+3<br />
+4<br />
= 10</p></blockquote>
<p><img src='http://silveiraneto.net/wp-content/uploads/2008/03/javaduk1.gif' alt='Java Duke animated gif waving' /></p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/03/21/numberformatexception-example/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Pointers to functions in C++</title>
		<link>http://silveiraneto.net/2008/03/16/pointers-to-functions-in-c/</link>
		<comments>http://silveiraneto.net/2008/03/16/pointers-to-functions-in-c/#comments</comments>
		<pubDate>Sun, 16 Mar 2008 23:11:57 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Cpp]]></category>
		<category><![CDATA[pointers]]></category>
		<category><![CDATA[programming]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/2008/03/16/pointers-to-functions-in-c/</guid>
		<description><![CDATA[<a href="http://silveiraneto.net/2008/03/16/pointers-to-functions-in-c/" title="Pointers to functions in C++"></a>I need to implements some codes in C++. Just remembering some concepts like pointers to functions. A simple example: #include &#60;stdlib.h&#62; #include &#60;iostream&#62; using namespace std; double evalFunction(double (*f)(double), double param){ return f(param); } double function(double x){ return x/2; } &#8230;<p class="read-more"><a href="http://silveiraneto.net/2008/03/16/pointers-to-functions-in-c/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://silveiraneto.net/2008/03/16/pointers-to-functions-in-c/" title="Pointers to functions in C++"></a><p>I need to implements some codes in C++. Just remembering some concepts like pointers to functions.</p>
<p>A simple example:</p>
<pre name="code" class="cpp">
#include &lt;stdlib.h&gt;
#include &lt;iostream&gt;

using namespace std;

double evalFunction(double (*f)(double), double param){
    return f(param);
}

double function(double x){
    return x/2;
}

int main(int argc, char** argv) {
    cout &lt;&lt; function(5.0) &lt;&lt; endl;
    cout &lt;&lt; evalFunction(function, 5.0) &lt;&lt; endl;
    return (EXIT_SUCCESS);
}
</pre>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/03/16/pointers-to-functions-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Simple Java Chronometer</title>
		<link>http://silveiraneto.net/2008/03/15/simple-java-chronometer/</link>
		<comments>http://silveiraneto.net/2008/03/15/simple-java-chronometer/#comments</comments>
		<pubDate>Sat, 15 Mar 2008 03:27:50 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[chronometer]]></category>
		<category><![CDATA[clock]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[currentTimeMillis]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[optimization]]></category>
		<category><![CDATA[processor]]></category>
		<category><![CDATA[snippet]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/2008/03/15/simple-java-chronometer/</guid>
		<description><![CDATA[<a href="http://silveiraneto.net/2008/03/15/simple-java-chronometer/" title="Simple Java Chronometer"></a>A very simple Java chronometer code (inspired in the chronometer code in Opale project) you can use for simples measures. In the main method there&#8217;s a example of use. public final class Chronometer&#123; private long begin, end; &#160; public void &#8230;<p class="read-more"><a href="http://silveiraneto.net/2008/03/15/simple-java-chronometer/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://silveiraneto.net/2008/03/15/simple-java-chronometer/" title="Simple Java Chronometer"></a><p>A very simple Java chronometer code (inspired in the chronometer code in <a href="http://savannah.nongnu.org/projects/opale/">Opale</a> project) you can use for simples measures.</p>
<p>In the main method there&#8217;s a example of use.</p>

<div class="wp_syntax"><div 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;">final</span> <span style="color: #000000; font-weight: bold;">class</span> Chronometer<span style="color: #009900;">&#123;</span>
    <span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">long</span> begin, end<span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> start<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        begin <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> stop<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
        end <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">long</span> getTime<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> end<span style="color: #339933;">-</span>begin<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">long</span> getMilliseconds<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> end<span style="color: #339933;">-</span>begin<span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">double</span> getSeconds<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: #009900;">&#40;</span>end <span style="color: #339933;">-</span> begin<span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">1000.0</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">double</span> getMinutes<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: #009900;">&#40;</span>end <span style="color: #339933;">-</span> begin<span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">60000.0</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">double</span> getHours<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: #009900;">&#40;</span>end <span style="color: #339933;">-</span> begin<span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">3600000.0</span><span style="color: #339933;">;</span>
    <span style="color: #009900;">&#125;</span>
&nbsp;
    <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> arg<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
        Chronometer ch <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Chronometer<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        ch.<span style="color: #006633;">start</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;">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;">1</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&lt;</span><span style="color: #cc66cc;">10000000</span><span style="color: #339933;">;</span>i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
        ch.<span style="color: #006633;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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>ch.<span style="color: #006633;">getTime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
        ch.<span style="color: #006633;">start</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;">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;">10000000</span><span style="color: #339933;">;</span>i<span style="color: #339933;">&gt;</span><span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>i<span style="color: #339933;">--</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span><span style="color: #009900;">&#125;</span>
        ch.<span style="color: #006633;">stop</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</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>ch.<span style="color: #006633;">getTime</span><span style="color: #009900;">&#40;</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: #009900;">&#125;</span></pre></div></div>

<p>Compiling and running this code gives you something like:</p>
<blockquote><p>191<br />
12</p></blockquote>
<p>Maybe you got surprised with this. The first loop, with 10 millions of steps is slower than the second, also with 10 millions of steps.</p>
<p>Why?</p>
<p>Some processors (like x86) have an zero-flag in their <a href="http://en.wikipedia.org/wiki/Arithmetic_Logic_Unit">ALU</a>. Using it is faster perform the question i≠0 than i&lt;K (for a K≠0). In a loop with 10 millions iterations this difference can be perceptible. And this is not just for Java. You can try those loops in others language and see this behavior.</p>
<p>Think twice next time you write a big loop. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/03/15/simple-java-chronometer/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Java, listing system properties</title>
		<link>http://silveiraneto.net/2008/03/10/java-listing-system-properties/</link>
		<comments>http://silveiraneto.net/2008/03/10/java-listing-system-properties/#comments</comments>
		<pubDate>Mon, 10 Mar 2008 16:23:17 +0000</pubDate>
		<dc:creator>Silveira</dc:creator>
				<category><![CDATA[english]]></category>
		<category><![CDATA[code]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[java.util]]></category>
		<category><![CDATA[program]]></category>
		<category><![CDATA[Programação]]></category>
		<category><![CDATA[programming]]></category>
		<category><![CDATA[Properties]]></category>

		<guid isPermaLink="false">http://silveiraneto.net/2008/03/10/java-listing-system-properties/</guid>
		<description><![CDATA[<a href="http://silveiraneto.net/2008/03/10/java-listing-system-properties/" title="Java, listing system properties"></a>This code prints out your system properties. import java.util.Properties; &#160; public class PropertiesLister&#123; public static void main &#40;String args&#91;&#93;&#41;&#123; Properties props = System.getProperties&#40;&#41;; props.list&#40;System.out&#41;; &#125; &#125; In the machine I&#8217;m writing right now: &#8211; listing properties &#8211; java.runtime.name=Java(TM) SE Runtime &#8230;<p class="read-more"><a href="http://silveiraneto.net/2008/03/10/java-listing-system-properties/">Read more &#187;</a></p>]]></description>
			<content:encoded><![CDATA[<a href="http://silveiraneto.net/2008/03/10/java-listing-system-properties/" title="Java, listing system properties"></a><p>This code prints out your system properties.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.Properties</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">class</span> PropertiesLister<span style="color: #009900;">&#123;</span>
   <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000066; font-weight: bold;">void</span> main <span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> args<span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
       <span style="color: #003399;">Properties</span> props <span style="color: #339933;">=</span> <span style="color: #003399;">System</span>.<span style="color: #006633;">getProperties</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       props.<span style="color: #006633;">list</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">System</span>.<span style="color: #006633;">out</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

<p>In the machine I&#8217;m writing right now:</p>
<blockquote><p>&#8211; listing properties &#8211;<br />
java.runtime.name=Java(TM) SE Runtime Environment<br />
sun.boot.library.path=/usr/lib/jvm/java-6-sun-1.6.0.00/jre/&#8230;<br />
java.vm.version=1.6.0-b105<br />
java.vm.vendor=Sun Microsystems Inc.<br />
java.vendor.url=http://java.sun.com/<br />
path.separator=:<br />
java.vm.name=Java HotSpot(TM) Server VM<br />
file.encoding.pkg=sun.io<br />
user.country=BR<br />
sun.java.launcher=SUN_STANDARD<br />
sun.os.patch.level=unknown<br />
java.vm.specification.name=Java Virtual Machine Specification<br />
user.dir=/tmp<br />
java.runtime.version=1.6.0-b105<br />
java.awt.graphicsenv=sun.awt.X11GraphicsEnvironment<br />
java.endorsed.dirs=/usr/lib/jvm/java-6-sun-1.6.0.00/jre/&#8230;<br />
os.arch=i386<br />
java.io.tmpdir=/tmp<br />
line.separator=</p>
<p>java.vm.specification.vendor=Sun Microsystems Inc.<br />
os.name=Linux<br />
sun.jnu.encoding=UTF-8<br />
java.library.path=/usr/lib/jvm/java-6-sun-1.6.0.00/jre/&#8230;<br />
java.specification.name=Java Platform API Specification<br />
java.class.version=50.0<br />
sun.management.compiler=HotSpot Server Compiler<br />
os.version=2.6.20-16-generic<br />
user.home=/home/export/silveira<br />
user.timezone=<br />
java.awt.printerjob=sun.print.PSPrinterJob<br />
file.encoding=UTF-8<br />
java.specification.version=1.6<br />
user.name=silveira<br />
java.class.path=.<br />
java.vm.specification.version=1.0<br />
sun.arch.data.model=32<br />
java.home=/usr/lib/jvm/java-6-sun-1.6.0.00/jre<br />
java.specification.vendor=Sun Microsystems Inc.<br />
user.language=pt<br />
java.vm.info=mixed mode<br />
java.version=1.6.0<br />
java.ext.dirs=/usr/lib/jvm/java-6-sun-1.6.0.00/jre/&#8230;<br />
sun.boot.class.path=/usr/lib/jvm/java-6-sun-1.6.0.00/jre/&#8230;<br />
java.vendor=Sun Microsystems Inc.<br />
file.separator=/<br />
java.vendor.url.bug=http://java.sun.com/cgi-bin/bugreport&#8230;<br />
sun.cpu.endian=little<br />
sun.io.unicode.encoding=UnicodeLittle<br />
sun.cpu.isalist=</p></blockquote>
<p>Try out at your home. :)</p>
]]></content:encoded>
			<wfw:commentRss>http://silveiraneto.net/2008/03/10/java-listing-system-properties/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

