<?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>Java, J# &#38; C# Notes &#187; Java</title>
	<atom:link href="http://robotics.icstweb.org/java-do-diez/category/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://robotics.icstweb.org/java-do-diez</link>
	<description></description>
	<lastBuildDate>Wed, 08 Sep 2010 21:26:30 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>how to run process</title>
		<link>http://robotics.icstweb.org/java-do-diez/2010/06/04/how-to-run-process/</link>
		<comments>http://robotics.icstweb.org/java-do-diez/2010/06/04/how-to-run-process/#comments</comments>
		<pubDate>Fri, 04 Jun 2010 21:26:40 +0000</pubDate>
		<dc:creator>Fieral</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[console]]></category>
		<category><![CDATA[parallel programming]]></category>
		<category><![CDATA[process]]></category>

		<guid isPermaLink="false">http://robotics.icstweb.org/java-do-diez/?p=80</guid>
		<description><![CDATA[Here is the way to wrap external console-executable stuff. private Process Process = null; String command = &#34;ping google.com&#34;; Runtime r = Runtime.getRuntime&#40;&#41;; Process = r.exec&#40;command&#41;; BufferedInputStream = new BufferedInputStream&#40;Process.getInputStream&#40;&#41;&#41;;// bytes from the process BufferedOutputStream = new BufferedOutputStream&#40;Process .getOutputStream&#40;&#41;&#41;;// bytes to the process ... Process.destroy&#40;&#41;; System.out.println&#40;&#34;------------------&#38;gt; Process killed.&#34;&#41;;]]></description>
			<content:encoded><![CDATA[<p>Here is the way to wrap external console-executable stuff.</p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #003399;">Process</span> <span style="color: #003399;">Process</span> <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
<span style="color: #003399;">String</span> command <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;ping google.com&quot;</span><span style="color: #339933;">;</span> 
<span style="color: #003399;">Runtime</span> r <span style="color: #339933;">=</span> <span style="color: #003399;">Runtime</span>.<span style="color: #006633;">getRuntime</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">Process</span> <span style="color: #339933;">=</span> r.<span style="color: #006633;">exec</span><span style="color: #009900;">&#40;</span>command<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">BufferedInputStream</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedInputStream</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Process</span>.<span style="color: #006633;">getInputStream</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: #666666; font-style: italic;">// bytes from the process</span>
		<span style="color: #003399;">BufferedOutputStream</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedOutputStream</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Process</span>	.<span style="color: #006633;">getOutputStream</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: #666666; font-style: italic;">// bytes to the process</span>
...
                <span style="color: #003399;">Process</span>.<span style="color: #006633;">destroy</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;------------------&amp;gt; Process killed.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://robotics.icstweb.org/java-do-diez/2010/06/04/how-to-run-process/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>how to create window (JFrame)</title>
		<link>http://robotics.icstweb.org/java-do-diez/2010/01/14/how-to-create-window-jframe/</link>
		<comments>http://robotics.icstweb.org/java-do-diez/2010/01/14/how-to-create-window-jframe/#comments</comments>
		<pubDate>Thu, 14 Jan 2010 14:05:33 +0000</pubDate>
		<dc:creator>Fieral</dc:creator>
				<category><![CDATA[GUI]]></category>
		<category><![CDATA[How-To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[javax.swing]]></category>

		<guid isPermaLink="false">http://robotics.icstweb.org/java-do-diez/?p=75</guid>
		<description><![CDATA[package triplane.gui; &#160; import java.awt.Color; import java.awt.Dimension; import java.awt.Graphics; import java.awt.Image; import java.awt.Toolkit; import java.awt.event.KeyEvent; import java.awt.event.KeyListener; import java.awt.image.BufferedImage; &#160; import javax.swing.JFrame; &#160; public class Window extends JFrame &#123; int h = 768; int w = 1024; Image Background; InputInterceptor Inter; &#160; public Window&#40;String Title, int H, int W, InputInterceptor Inter&#41; &#123; this.Inter = Inter; [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">triplane.gui</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Color</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Dimension</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Graphics</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Image</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.Toolkit</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.event.KeyEvent</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.event.KeyListener</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.image.BufferedImage</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.swing.JFrame</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> <span style="color: #003399;">Window</span> <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">JFrame</span> <span style="color: #009900;">&#123;</span>
	<span style="color: #000066; font-weight: bold;">int</span> h <span style="color: #339933;">=</span> <span style="color: #cc66cc;">768</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">int</span> w <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1024</span><span style="color: #339933;">;</span>
	<span style="color: #003399;">Image</span> Background<span style="color: #339933;">;</span>
	InputInterceptor Inter<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Window</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> Title, <span style="color: #000066; font-weight: bold;">int</span> H, <span style="color: #000066; font-weight: bold;">int</span> W, InputInterceptor Inter<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">Inter</span> <span style="color: #339933;">=</span> Inter<span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">Background</span> <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">BufferedImage</span><span style="color: #009900;">&#40;</span>W, H, <span style="color: #003399;">BufferedImage</span>.<span style="color: #006633;">TYPE_INT_RGB</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// test();</span>
&nbsp;
		setTitle<span style="color: #009900;">&#40;</span>Title<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		setMinimumSize<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Dimension</span><span style="color: #009900;">&#40;</span>W, H<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		setMaximumSize<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">Dimension</span><span style="color: #009900;">&#40;</span>W, H<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		setResizable<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">false</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">JFrame</span>.<span style="color: #006633;">setDefaultLookAndFeelDecorated</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003399;">Toolkit</span> tk <span style="color: #339933;">=</span> <span style="color: #003399;">Toolkit</span>.<span style="color: #006633;">getDefaultToolkit</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">Dimension</span> screenSize <span style="color: #339933;">=</span> tk.<span style="color: #006633;">getScreenSize</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> h <span style="color: #339933;">=</span> screenSize.<span style="color: #006633;">height</span><span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">int</span> w <span style="color: #339933;">=</span> screenSize.<span style="color: #006633;">width</span><span style="color: #339933;">;</span>
&nbsp;
		setLocation<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>w <span style="color: #339933;">-</span> W<span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span>, <span style="color: #009900;">&#40;</span>h <span style="color: #339933;">-</span> H<span style="color: #009900;">&#41;</span> <span style="color: #339933;">/</span> <span style="color: #cc66cc;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// 2. Optional: What happens when the frame closes?</span>
		setDefaultCloseOperation<span style="color: #009900;">&#40;</span><span style="color: #003399;">JFrame</span>.<span style="color: #006633;">EXIT_ON_CLOSE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		addWindowListener<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">Inter</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		addKeyListener<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">Inter</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		addMouseListener<span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">Inter</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// 3. Create components and put them in the frame.</span>
		<span style="color: #666666; font-style: italic;">// ...create emptyLabel...</span>
		<span style="color: #666666; font-style: italic;">// frame.getContentPane().add(emptyLabel, BorderLayout.CENTER);</span>
		getContentPane<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// 4. Size the frame.</span>
		pack<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #666666; font-style: italic;">// 5. Show it.</span>
		setVisible<span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> test<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</span>
		<span style="color: #666666; font-style: italic;">// BufferedImage im = new BufferedImage(600, 400,</span>
		<span style="color: #666666; font-style: italic;">// BufferedImage.TYPE_INT_RGB);</span>
		<span style="color: #666666; font-style: italic;">// Graphics g = im.getGraphics();</span>
		<span style="color: #666666; font-style: italic;">// g.setColor(Color.RED);</span>
		<span style="color: #666666; font-style: italic;">// g.drawLine(0, 0, 100, 100);</span>
		<span style="color: #666666; font-style: italic;">// I.put(im);</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> paint<span style="color: #009900;">&#40;</span><span style="color: #003399;">Graphics</span> g<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">setBackground</span><span style="color: #009900;">&#40;</span><span style="color: #003399;">Color</span>.<span style="color: #006633;">BLACK</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		g.<span style="color: #006633;">drawImage</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">Background</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #cc66cc;">0</span>, <span style="color: #000000; font-weight: bold;">this</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// if (I != null) {</span>
		<span style="color: #666666; font-style: italic;">// if (I.check_availability()) {</span>
		<span style="color: #666666; font-style: italic;">// Image i = I.get();</span>
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">// g.drawImage(i, (this.getWidth() - i.getWidth(this)) / 2, (this</span>
		<span style="color: #666666; font-style: italic;">// .getHeight() - i.getHeight(this)) / 2, this);</span>
		<span style="color: #666666; font-style: italic;">// }</span>
		<span style="color: #666666; font-style: italic;">// }</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> update<span style="color: #009900;">&#40;</span><span style="color: #003399;">Graphics</span> g<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		paint<span style="color: #009900;">&#40;</span>g<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>


<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">triplane.gui</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.event.ActionEvent</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.event.ActionListener</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.event.KeyEvent</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.event.KeyListener</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.event.MouseEvent</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.event.MouseListener</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.event.WindowEvent</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.awt.event.WindowListener</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> InputInterceptor <span style="color: #000000; font-weight: bold;">implements</span> <span style="color: #003399;">KeyListener</span>, <span style="color: #003399;">ActionListener</span>,
		<span style="color: #003399;">MouseListener</span>, <span style="color: #003399;">WindowListener</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> keyPressed<span style="color: #009900;">&#40;</span><span style="color: #003399;">KeyEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</span>
&nbsp;
		<span style="color: #003399;">System</span>.<span style="color: #006633;">out</span>.<span style="color: #006633;">println</span><span style="color: #009900;">&#40;</span>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> keyReleased<span style="color: #009900;">&#40;</span><span style="color: #003399;">KeyEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</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>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> keyTyped<span style="color: #009900;">&#40;</span><span style="color: #003399;">KeyEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</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>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> actionPerformed<span style="color: #009900;">&#40;</span><span style="color: #003399;">ActionEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</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>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> mouseClicked<span style="color: #009900;">&#40;</span><span style="color: #003399;">MouseEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</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>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> mouseEntered<span style="color: #009900;">&#40;</span><span style="color: #003399;">MouseEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</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>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> mouseExited<span style="color: #009900;">&#40;</span><span style="color: #003399;">MouseEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</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>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> mousePressed<span style="color: #009900;">&#40;</span><span style="color: #003399;">MouseEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</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>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> mouseReleased<span style="color: #009900;">&#40;</span><span style="color: #003399;">MouseEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</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>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> windowActivated<span style="color: #009900;">&#40;</span><span style="color: #003399;">WindowEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</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>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> windowClosed<span style="color: #009900;">&#40;</span><span style="color: #003399;">WindowEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</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>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> windowClosing<span style="color: #009900;">&#40;</span><span style="color: #003399;">WindowEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</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>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> windowDeactivated<span style="color: #009900;">&#40;</span><span style="color: #003399;">WindowEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</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>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> windowDeiconified<span style="color: #009900;">&#40;</span><span style="color: #003399;">WindowEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</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>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> windowIconified<span style="color: #009900;">&#40;</span><span style="color: #003399;">WindowEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</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>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	@Override
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> windowOpened<span style="color: #009900;">&#40;</span><span style="color: #003399;">WindowEvent</span> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</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>e<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

<p><a href="http://robotics.icstweb.org/java-do-diez/files/2010/01/see.jpg"><img src="http://robotics.icstweb.org/java-do-diez/files/2010/01/see-300x187.jpg" alt="see" title="see" width="300" height="187" class="aligncenter size-medium wp-image-78" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://robotics.icstweb.org/java-do-diez/2010/01/14/how-to-create-window-jframe/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java Architecture for XML Binding (JAXB)</title>
		<link>http://robotics.icstweb.org/java-do-diez/2009/04/21/java-architecture-for-xml-binding-jaxb/</link>
		<comments>http://robotics.icstweb.org/java-do-diez/2009/04/21/java-architecture-for-xml-binding-jaxb/#comments</comments>
		<pubDate>Tue, 21 Apr 2009 10:40:30 +0000</pubDate>
		<dc:creator>Fieral</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[Serialization]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://robotics.icstweb.org/java-do-diez/?p=69</guid>
		<description><![CDATA[http://java.sun.com/developer/technicalArticles/WebServices/jaxb/ package rebecca.e.remote; &#160; import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.InputStream; import java.io.OutputStream; &#160; import javax.xml.bind.JAXBContext; import javax.xml.bind.JAXBException; import javax.xml.bind.Marshaller; import javax.xml.bind.Unmarshaller; &#160; public class XMLMarshal &#123; &#160; public Object UnMurshall&#40;String xml, String packageName&#41; throws JAXBException &#123; JAXBContext jc = JAXBContext.newInstance&#40;packageName&#41;; Unmarshaller u = jc.createUnmarshaller&#40;&#41;; InputStream is = new ByteArrayInputStream&#40;xml.getBytes&#40;&#41;&#41;; return u.unmarshal&#40;is&#41;; &#125; &#160; public String [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://java.sun.com/developer/technicalArticles/WebServices/jaxb/">http://java.sun.com/developer/technicalArticles/WebServices/jaxb/</a></p>
<p><img src="http://java.sun.com/developer/technicalArticles/WebServices/jaxb/xml_schema_fig1.gif" alt="http://java.sun.com/developer/technicalArticles/WebServices/jaxb/xml_schema_fig1.gif" /></p>

<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">rebecca.e.remote</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.ByteArrayInputStream</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.ByteArrayOutputStream</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.InputStream</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.OutputStream</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.bind.JAXBContext</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.bind.JAXBException</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.bind.Marshaller</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">javax.xml.bind.Unmarshaller</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> XMLMarshal <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">Object</span> UnMurshall<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> xml, <span style="color: #003399;">String</span> packageName<span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">throws</span> JAXBException <span style="color: #009900;">&#123;</span>
		JAXBContext jc <span style="color: #339933;">=</span> JAXBContext.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span>packageName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		Unmarshaller u <span style="color: #339933;">=</span> jc.<span style="color: #006633;">createUnmarshaller</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">InputStream</span> is <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ByteArrayInputStream</span><span style="color: #009900;">&#40;</span>xml.<span style="color: #006633;">getBytes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> u.<span style="color: #006633;">unmarshal</span><span style="color: #009900;">&#40;</span>is<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: #003399;">String</span> Murshall<span style="color: #009900;">&#40;</span><span style="color: #003399;">Object</span> xmlObject, <span style="color: #003399;">String</span> packageName<span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">throws</span> JAXBException <span style="color: #009900;">&#123;</span>
&nbsp;
		JAXBContext jc <span style="color: #339933;">=</span> JAXBContext.<span style="color: #006633;">newInstance</span><span style="color: #009900;">&#40;</span>packageName<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		Marshaller m <span style="color: #339933;">=</span> jc.<span style="color: #006633;">createMarshaller</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		m.<span style="color: #006633;">setProperty</span><span style="color: #009900;">&#40;</span>Marshaller.<span style="color: #006633;">JAXB_FORMATTED_OUTPUT</span>, <span style="color: #003399;">Boolean</span>.<span style="color: #000066; font-weight: bold;">TRUE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">ByteArrayOutputStream</span> is <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ByteArrayOutputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		m.<span style="color: #006633;">marshal</span><span style="color: #009900;">&#40;</span>xmlObject, is<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #000000; font-weight: bold;">return</span> is.<span style="color: #006633;">toString</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: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://robotics.icstweb.org/java-do-diez/2009/04/21/java-architecture-for-xml-binding-jaxb/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>java files</title>
		<link>http://robotics.icstweb.org/java-do-diez/2009/04/15/java-files/</link>
		<comments>http://robotics.icstweb.org/java-do-diez/2009/04/15/java-files/#comments</comments>
		<pubDate>Wed, 15 Apr 2009 12:53:19 +0000</pubDate>
		<dc:creator>Fieral</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[java.lang.io]]></category>

		<guid isPermaLink="false">http://robotics.icstweb.org/java-do-diez/?p=67</guid>
		<description><![CDATA[package rebecca.e.util.io; &#160; import java.io.ByteArrayOutputStream; import java.io.DataInputStream; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; import java.util.List; &#160; public class FilePacker &#123; /// Save FileData from memory to File public void String2File&#40;String f, String data, boolean b&#41; throws IOException &#123; // TODO Auto-generated method stub if &#40;b&#41; System.out.println&#40;&#34;Writing: &#34; + f&#41;; FileOutputStream fos = new FileOutputStream&#40;f&#41;; fos.write&#40;data.getBytes&#40;&#41;&#41;; [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">rebecca.e.util.io</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.ByteArrayOutputStream</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.DataInputStream</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.FileInputStream</span><span style="color: #339933;">;</span>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.io.FileOutputStream</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>
<span style="color: #000000; font-weight: bold;">import</span> <span style="color: #006699;">java.util.List</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> FilePacker <span style="color: #009900;">&#123;</span>
            <span style="color: #666666; font-style: italic;">/// Save FileData from memory to File</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> String2File<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> f, <span style="color: #003399;">String</span> data, <span style="color: #000066; font-weight: bold;">boolean</span> b<span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#41;</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;Writing: &quot;</span> <span style="color: #339933;">+</span> f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #003399;">FileOutputStream</span> fos <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileOutputStream</span><span style="color: #009900;">&#40;</span>f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		fos.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>data.<span style="color: #006633;">getBytes</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		fos.<span style="color: #006633;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		fos.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">void</span> printfile<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> p, <span style="color: #003399;">File</span> f<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>p <span style="color: #339933;">+</span> f.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;:&quot;</span> <span style="color: #339933;">+</span> f.<span style="color: #006633;">getData</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: #666666; font-style: italic;">// this.Attributes.get(i)</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">void</span> printfolder<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> p, Dir d<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		print0<span style="color: #009900;">&#40;</span>p, d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
            <span style="color: #666666; font-style: italic;">/// Print loaded folder tree</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> print<span style="color: #009900;">&#40;</span>Dir d<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">print0</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span>, d<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
            <span style="color: #666666; font-style: italic;">/// Print loaded file</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> print<span style="color: #009900;">&#40;</span><span style="color: #003399;">File</span> f<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">printfile</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot; &quot;</span>, f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000066; font-weight: bold;">void</span> print0<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> p, Dir d<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>p <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; &quot;</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;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> d.<span style="color: #006633;">getFolder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">printfolder</span><span style="color: #009900;">&#40;</span>p <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;   &quot;</span>, d.<span style="color: #006633;">getFolder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> d.<span style="color: #006633;">getFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">printfile</span><span style="color: #009900;">&#40;</span>p <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; &quot;</span>, d.<span style="color: #006633;">getFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>i<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;">// // TODO Auto-generated method stub</span>
		<span style="color: #666666; font-style: italic;">// String t0 = p + t + &quot;\n&quot;;</span>
		<span style="color: #666666; font-style: italic;">// t0 = t0 + p + &quot;&quot;;</span>
		<span style="color: #666666; font-style: italic;">// for (int i = 0; i &amp;lt; this.Attributes.size(); i++) {</span>
		<span style="color: #666666; font-style: italic;">// t0 = t0 + p + Attributes.getKey(i) + &quot;:&quot; + this.Attributes.get(i)</span>
		<span style="color: #666666; font-style: italic;">// + &quot;\n&quot;;</span>
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">// }</span>
		<span style="color: #666666; font-style: italic;">// for (int i = 0; i &amp;lt; this.SubNodes.size(); i++) {</span>
		<span style="color: #666666; font-style: italic;">// print0(&quot; &quot; + p, SubNodes.get(i).toString());</span>
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">// }</span>
		<span style="color: #666666; font-style: italic;">//</span>
		<span style="color: #666666; font-style: italic;">// return t0;</span>
	<span style="color: #009900;">&#125;</span>
            <span style="color: #666666; font-style: italic;">/// Load file to memory (String)</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #003399;">String</span> File2String<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> f, <span style="color: #000066; font-weight: bold;">boolean</span> b<span style="color: #009900;">&#41;</span> <span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</span>
		<span style="color: #003399;">FileInputStream</span> fstream<span style="color: #339933;">;</span>
		<span style="color: #003399;">DataInputStream</span> in<span style="color: #339933;">;</span>
		<span style="color: #000066; font-weight: bold;">int</span> bb<span style="color: #339933;">;</span>
		fstream <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">FileInputStream</span><span style="color: #009900;">&#40;</span>f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		in <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">DataInputStream</span><span style="color: #009900;">&#40;</span>fstream<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003399;">ByteArrayOutputStream</span> out <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #003399;">ByteArrayOutputStream</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>b<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;Reading: &quot;</span> <span style="color: #339933;">+</span> f<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>bb <span style="color: #339933;">=</span> in.<span style="color: #006633;">read</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: #339933;">-</span><span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
			out.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>bb<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
		<span style="color: #003399;">String</span> s <span style="color: #339933;">=</span> out.<span style="color: #006633;">toString</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		out.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">// -Djava.security.policy=C:/rmi.plc</span>
		in.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		fstream.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">return</span> s<span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
            <span style="color: #666666; font-style: italic;">/// Platform-independent File (Dir) separator</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #003399;">String</span> iV <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;file.separator&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
           <span style="color: #666666; font-style: italic;">///Archiving</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> addFile2Dir<span style="color: #009900;">&#40;</span>Dir D, <span style="color: #003399;">String</span> filePath, <span style="color: #000066; font-weight: bold;">boolean</span> b<span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span>
		java.<span style="color: #006633;">io</span>.<span style="color: #003399;">File</span> f <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> java.<span style="color: #006633;">io</span>.<span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>filePath<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>f.<span style="color: #006633;">isFile</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>
			<span style="color: #003399;">File</span> F <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: #009900;">&#41;</span><span style="color: #339933;">;</span>
			F.<span style="color: #006633;">setName</span><span style="color: #009900;">&#40;</span>f.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			F.<span style="color: #006633;">setData</span><span style="color: #009900;">&#40;</span><span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">File2String</span><span style="color: #009900;">&#40;</span>filePath, <span style="color: #000066; font-weight: bold;">true</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// F.setData(&quot;some data&quot;);</span>
			D.<span style="color: #006633;">getFile</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>F<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		<span style="color: #009900;">&#125;</span>
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>f.<span style="color: #006633;">isDirectory</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>
			Dir Dr <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Dir<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			Dr.<span style="color: #006633;">setName</span><span style="color: #009900;">&#40;</span>f.<span style="color: #006633;">getName</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;">String</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> l <span style="color: #339933;">=</span> f.<span style="color: #006633;">list</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			<span style="color: #000000; font-weight: bold;">for</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span> i <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> l.<span style="color: #006633;">length</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				<span style="color: #000000; font-weight: bold;">this</span>.<span style="color: #006633;">addFile2Dir</span><span style="color: #009900;">&#40;</span>Dr, filePath <span style="color: #339933;">+</span> iV <span style="color: #339933;">+</span> l<span style="color: #009900;">&#91;</span>i<span style="color: #009900;">&#93;</span>, b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>
			D.<span style="color: #006633;">getFolder</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>Dr<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: #666666; font-style: italic;">///Extracting</span>
	<span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> ExtractToFolder<span style="color: #009900;">&#40;</span>Dir d, <span style="color: #003399;">String</span> Dir, <span style="color: #000066; font-weight: bold;">boolean</span> b<span style="color: #009900;">&#41;</span>
			<span style="color: #000000; font-weight: bold;">throws</span> <span style="color: #003399;">IOException</span> <span style="color: #009900;">&#123;</span>
&nbsp;
		mkDir<span style="color: #009900;">&#40;</span>Dir, b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #003399;">List</span> l <span style="color: #339933;">=</span> d.<span style="color: #006633;">getFile</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;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> l.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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: #003399;">File</span> f <span style="color: #339933;">=</span> l.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">String</span> name <span style="color: #339933;">=</span> f.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">String</span> data <span style="color: #339933;">=</span> f.<span style="color: #006633;">getData</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
			String2File<span style="color: #009900;">&#40;</span>Dir <span style="color: #339933;">+</span> iV <span style="color: #339933;">+</span> name, data, b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
&nbsp;
		<span style="color: #003399;">List</span> j <span style="color: #339933;">=</span> d.<span style="color: #006633;">getFolder</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;">0</span><span style="color: #339933;">;</span> i <span style="color: #339933;">&amp;</span>lt<span style="color: #339933;">;</span> j.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> i<span style="color: #339933;">++</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
			Dir f <span style="color: #339933;">=</span> j.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span>i<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #003399;">String</span> name <span style="color: #339933;">=</span> f.<span style="color: #006633;">getName</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			mkDir<span style="color: #009900;">&#40;</span>Dir <span style="color: #339933;">+</span> iV <span style="color: #339933;">+</span> name, b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			ExtractToFolder<span style="color: #009900;">&#40;</span>f, Dir <span style="color: #339933;">+</span> iV <span style="color: #339933;">+</span> name, b<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #666666; font-style: italic;">// String2File(Dir + iV + name, data, b);</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000066; font-weight: bold;">void</span> mkDir<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> Dir, <span style="color: #000066; font-weight: bold;">boolean</span> b<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// TODO Auto-generated method stub</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#41;</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;Creating: &quot;</span> <span style="color: #339933;">+</span> Dir<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #000000; font-weight: bold;">new</span> java.<span style="color: #006633;">io</span>.<span style="color: #003399;">File</span><span style="color: #009900;">&#40;</span>Dir<span style="color: #009900;">&#41;</span>.<span style="color: #006633;">mkdir</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>
			<span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>b<span style="color: #009900;">&#41;</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;Unable to create folder: &quot;</span> <span style="color: #339933;">+</span> Dir <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot; &quot;</span>
						<span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;(Already exist?)&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
		<span style="color: #009900;">&#125;</span>
&nbsp;
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://robotics.icstweb.org/java-do-diez/2009/04/15/java-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How to: RMI</title>
		<link>http://robotics.icstweb.org/java-do-diez/2009/02/05/how-to-rmi/</link>
		<comments>http://robotics.icstweb.org/java-do-diez/2009/02/05/how-to-rmi/#comments</comments>
		<pubDate>Thu, 05 Feb 2009 11:07:52 +0000</pubDate>
		<dc:creator>Fieral</dc:creator>
				<category><![CDATA[How-To]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[RMI]]></category>

		<guid isPermaLink="false">http://robotics.icstweb.org/java-do-diez/?p=65</guid>
		<description><![CDATA[Steps to creation of an RMI system: The short version 1) Create an interface. (in this case, the interface is myRMIInterface.java). 2) Create a class that implements the interface. (in this case, myRMIImpl.java). 3) Create a server that creates an instance of this class 4) Create a client that connects to the server object using [...]]]></description>
			<content:encoded><![CDATA[<p>Steps to creation of an RMI system: </p>
<p>The short version<br />
1) Create an interface. (in this case, the interface is myRMIInterface.java).<br />
2) Create a class that implements the interface. (in this case, myRMIImpl.java).<br />
3) Create a server that creates an instance of this class<br />
4) Create a client that connects to the server object using Naming.lookup()<br />
5) Compile these classes.<br />
6) Run the RMI interface compiler on the .class file of the implementation<br />
   class (in this case, you&#8217;d say &#8220;rmic myRMIImpl&#8221;).<br />
7) Start the RMI registry (on Windows NT/95, say &#8220;start rmiregistry&#8221;).<br />
8) Start the server class (&#8220;start java myRMIServer&#8221;).<br />
9) Run the client program (&#8220;java myRMIClient&#8221;).</p>
<p>The long version: <a href="http://patriot.net/~tvalesky/easyrmi.html">http://patriot.net/~tvalesky/easyrmi.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://robotics.icstweb.org/java-do-diez/2009/02/05/how-to-rmi/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>read from console java example</title>
		<link>http://robotics.icstweb.org/java-do-diez/2009/02/04/read-from-console-java-example/</link>
		<comments>http://robotics.icstweb.org/java-do-diez/2009/02/04/read-from-console-java-example/#comments</comments>
		<pubDate>Wed, 04 Feb 2009 15:50:03 +0000</pubDate>
		<dc:creator>Fieral</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://robotics.icstweb.org/java-do-diez/?p=63</guid>
		<description><![CDATA[import java.util.Scanner; &#160; public class InputExp &#123; &#160; public static void main&#40;String&#91;&#93; args&#41; &#123; &#160; String name; int age; Scanner in = new Scanner&#40;System.in&#41;; &#160; // Reads a single line from the console // and stores into name variable name = in.nextLine&#40;&#41;; &#160; // Reads a integer from the console // and stores into age [...]]]></description>
			<content:encoded><![CDATA[
<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.Scanner</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> InputExp <span style="color: #009900;">&#123;</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> args<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
       <span style="color: #003399;">String</span> name<span style="color: #339933;">;</span>
       <span style="color: #000066; font-weight: bold;">int</span> age<span style="color: #339933;">;</span>
       Scanner in <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Scanner<span style="color: #009900;">&#40;</span><span style="color: #003399;">System</span>.<span style="color: #006633;">in</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
       <span style="color: #666666; font-style: italic;">// Reads a single line from the console </span>
       <span style="color: #666666; font-style: italic;">// and stores into name variable</span>
       name <span style="color: #339933;">=</span> in.<span style="color: #006633;">nextLine</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
       <span style="color: #666666; font-style: italic;">// Reads a integer from the console</span>
       <span style="color: #666666; font-style: italic;">// and stores into age variable</span>
       age<span style="color: #339933;">=</span>in.<span style="color: #006633;">nextInt</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       in.<span style="color: #006633;">close</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>            
&nbsp;
       <span style="color: #666666; font-style: italic;">// Prints name and age to the console</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;Name :&quot;</span><span style="color: #339933;">+</span>name<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;Age :&quot;</span><span style="color: #339933;">+</span>age<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
    <span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://robotics.icstweb.org/java-do-diez/2009/02/04/read-from-console-java-example/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HollyShitException</title>
		<link>http://robotics.icstweb.org/java-do-diez/2009/01/26/hollyshitexception/</link>
		<comments>http://robotics.icstweb.org/java-do-diez/2009/01/26/hollyshitexception/#comments</comments>
		<pubDate>Mon, 26 Jan 2009 17:32:04 +0000</pubDate>
		<dc:creator>Fieral</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[fun]]></category>

		<guid isPermaLink="false">http://robotics.icstweb.org/java-do-diez/?p=57</guid>
		<description><![CDATA[package rebecca.e.util; &#160; public class HollyShitException extends RuntimeException &#123; &#160; private static final long serialVersionUID = 1811988306094364489L; &#160; public HollyShitException&#40;String Message&#41; &#123; super&#40;&#34;Holly shit! \n&#34; + Message&#41;; &#125; &#160; &#125;]]></description>
			<content:encoded><![CDATA[
<div class="wp_syntax"><div class="code"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">package</span> <span style="color: #006699;">rebecca.e.util</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> HollyShitException <span style="color: #000000; font-weight: bold;">extends</span> <span style="color: #003399;">RuntimeException</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <span style="color: #000066; font-weight: bold;">long</span> serialVersionUID <span style="color: #339933;">=</span> 1811988306094364489L<span style="color: #339933;">;</span>
&nbsp;
	<span style="color: #000000; font-weight: bold;">public</span> HollyShitException<span style="color: #009900;">&#40;</span><span style="color: #003399;">String</span> Message<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		<span style="color: #000000; font-weight: bold;">super</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Holly shit! <span style="color: #000099; font-weight: bold;">\n</span>&quot;</span> <span style="color: #339933;">+</span> Message<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
&nbsp;
<span style="color: #009900;">&#125;</span></pre></div></div>

]]></content:encoded>
			<wfw:commentRss>http://robotics.icstweb.org/java-do-diez/2009/01/26/hollyshitexception/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>ReentrantLock</title>
		<link>http://robotics.icstweb.org/java-do-diez/2009/01/20/reentrantlock/</link>
		<comments>http://robotics.icstweb.org/java-do-diez/2009/01/20/reentrantlock/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 13:19:41 +0000</pubDate>
		<dc:creator>Fieral</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[parallel programming]]></category>

		<guid isPermaLink="false">http://robotics.icstweb.org/java-do-diez/?p=54</guid>
		<description><![CDATA[http://en.wikipedia.org/wiki/Dining_philosophers_problem http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/locks/ReentrantLock.html A reentrant mutual exclusion Lock with the same basic behavior and semantics as the implicit monitor lock accessed using synchronized methods and statements, but with extended capabilities. A ReentrantLock is owned by the thread last successfully locking, but not yet unlocking it. A thread invoking lock will return, successfully acquiring the lock, when [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://en.wikipedia.org/wiki/Dining_philosophers_problem">http://en.wikipedia.org/wiki/Dining_philosophers_problem</a></p>
<p><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/locks/ReentrantLock.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/concurrent/locks/ReentrantLock.html</a></p>
<p>A reentrant mutual exclusion <a title="interface in java.util.concurrent.locks" href="../../../../java/util/concurrent/locks/Lock.html"><code>Lock</code></a> with the same basic<br />
behavior and semantics as the implicit monitor lock accessed using<br />
<tt>synchronized</tt> methods and statements, but with extended<br />
capabilities.</p>
<p>A <tt>ReentrantLock</tt> is <em>owned</em> by the thread last<br />
successfully locking, but not yet unlocking it. A thread invoking<br />
<tt>lock</tt> will return, successfully acquiring the lock, when<br />
the lock is not owned by another thread. The method will return<br />
immediately if the current thread already owns the lock. This can<br />
be checked using methods <a href="../../../../java/util/concurrent/locks/ReentrantLock.html#isHeldByCurrentThread()"><code>isHeldByCurrentThread()</code></a>, and <a href="../../../../java/util/concurrent/locks/ReentrantLock.html#getHoldCount()"><code>getHoldCount()</code></a>.</p>
<p>The constructor for this class accepts an optional<br />
<em>fairness</em> parameter.  When set <tt>true</tt>, under<br />
contention, locks favor granting access to the longest-waiting<br />
thread.  Otherwise this lock does not guarantee any particular<br />
access order.  Programs using fair locks accessed by many threads<br />
may display lower overall throughput (i.e., are slower; often much<br />
slower) than those using the default setting, but have smaller<br />
variances in times to obtain locks and guarantee lack of<br />
starvation. Note however, that fairness of locks does not guarantee<br />
fairness of thread scheduling. Thus, one of many threads using a<br />
fair lock may obtain it multiple times in succession while other<br />
active threads are not progressing and not currently holding the<br />
lock.<br />
Also note that the untimed <a href="../../../../java/util/concurrent/locks/ReentrantLock.html#tryLock()"><code>tryLock</code></a> method does not<br />
honor the fairness setting. It will succeed if the lock<br />
is available even if other threads are waiting.</p>
<p>It is recommended practice to <em>always</em> immediately<br />
follow a call to <tt>lock</tt> with a <tt>try</tt> block, most<br />
typically in a before/after construction such as:</p>
<pre> class X {
   private final ReentrantLock lock = new ReentrantLock();
   // ...

   public void m() {
     lock.lock();  // block until condition holds
     try {
       // ... method body
     } finally {
       lock.unlock()
     }
   }
 }</pre>
]]></content:encoded>
			<wfw:commentRss>http://robotics.icstweb.org/java-do-diez/2009/01/20/reentrantlock/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>UniMod</title>
		<link>http://robotics.icstweb.org/java-do-diez/2009/01/20/unimod/</link>
		<comments>http://robotics.icstweb.org/java-do-diez/2009/01/20/unimod/#comments</comments>
		<pubDate>Tue, 20 Jan 2009 09:34:13 +0000</pubDate>
		<dc:creator>Fieral</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[eclipse]]></category>

		<guid isPermaLink="false">http://robotics.icstweb.org/java-do-diez/?p=52</guid>
		<description><![CDATA[http://unimod.sourceforge.net/ UniMod states for Unified Modeling. Long term project goal is to create unified methodology for application development process that will close the gap between Design and Development phases. Currently, UniMod project is focused on designing and implementing applications behavior. Already implemented approach adapts SWITCH-technology for UML notation. SWITCH-technology is also known as Automata-based Programming [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://unimod.sourceforge.net/">http://unimod.sourceforge.net/</a></p>
<p>UniMod states for Unified Modeling. Long term project goal is to create unified methodology for application development process that will close the gap between Design and Development phases.</p>
<p>Currently, UniMod project is focused on designing and implementing applications behavior. Already implemented approach adapts SWITCH-technology for UML notation. SWITCH-technology is also known as Automata-based Programming and has it&#8217;s own Russian site http://is.ifmo.ru/english/.</p>
<p>SWITCH-technology suggests to model application behavior with a help of Structural Finite State Machine (FSM). Structural FSM is defined as set of Abstract FSMs and scheme of Abstract FSMs interconnections.</p>
<p>Eclipse plugin:<br />
<a href="http://unimod.sourceforge.net/eclipse-plugin.html">http://unimod.sourceforge.net/eclipse-plugin.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://robotics.icstweb.org/java-do-diez/2009/01/20/unimod/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Tutorial : XML generation with JAVA</title>
		<link>http://robotics.icstweb.org/java-do-diez/2009/01/07/tutorial-xml-generation-with-java/</link>
		<comments>http://robotics.icstweb.org/java-do-diez/2009/01/07/tutorial-xml-generation-with-java/#comments</comments>
		<pubDate>Wed, 07 Jan 2009 14:55:56 +0000</pubDate>
		<dc:creator>Fieral</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[xml]]></category>

		<guid isPermaLink="false">http://robotics.icstweb.org/java-do-diez/?p=48</guid>
		<description><![CDATA[http://javazoom.net/services/newsletter/xmlgeneration.html (5) &#8211; JAXP + SAX + Serialization to servlet output stream : JDK 1.4 compliant &#8211; import java.io.*; // SAX classes. import org.xml.sax.*; import org.xml.sax.helpers.*; //JAXP 1.1 import javax.xml.parsers.*; import javax.xml.transform.*; import javax.xml.transform.stream.*; import javax.xml.transform.sax.*; [...] // PrintWriter from a Servlet PrintWriter out = response.getWriter(); StreamResult streamResult = new StreamResult(out); SAXTransformerFactory tf = (SAXTransformerFactory) [...]]]></description>
			<content:encoded><![CDATA[<p><a title="http://javazoom.net/services/newsletter/xmlgeneration.html" href="http://javazoom.net/services/newsletter/xmlgeneration.html">http://javazoom.net/services/newsletter/xmlgeneration.html</a></p>
<p><strong>(5) &#8211; JAXP + SAX + Serialization to servlet output stream : JDK 1.4 compliant &#8211; </strong><br />
<code><br />
import java.io.*;<br />
// SAX classes.<br />
import org.xml.sax.*;<br />
import org.xml.sax.helpers.*;<br />
//JAXP 1.1<br />
import javax.xml.parsers.*;<br />
import javax.xml.transform.*;<br />
import javax.xml.transform.stream.*;<br />
import javax.xml.transform.sax.*;<br />
[...]<br />
// PrintWriter from a Servlet<br />
PrintWriter out = response.getWriter();<br />
StreamResult streamResult = new StreamResult(out);<br />
SAXTransformerFactory tf = (SAXTransformerFactory) SAXTransformerFactory.newInstance();<br />
// SAX2.0 ContentHandler.<br />
TransformerHandler hd = tf.newTransformerHandler();<br />
Transformer serializer = hd.getTransformer();<br />
serializer.setOutputProperty(OutputKeys.ENCODING,"ISO-8859-1");<br />
serializer.setOutputProperty(OutputKeys.DOCTYPE_SYSTEM,"users.dtd");<br />
serializer.setOutputProperty(OutputKeys.INDENT,"yes");<br />
hd.setResult(streamResult);<br />
hd.startDocument();<br />
AttributesImpl atts = new AttributesImpl();<br />
// USERS tag.<br />
hd.startElement("","","USERS",atts);<br />
// USER tags.<br />
String[] id = {"PWD122","MX787","A4Q45"};<br />
String[] type = {"customer","manager","employee"};<br />
String[] desc = {"Tim@Home","Jack&amp;Moud","John D'oé"};<br />
for (int i=0;i {<br />
atts.clear();<br />
atts.addAttribute("","","ID","CDATA",id[i]);<br />
atts.addAttribute("","","TYPE","CDATA",type[i]);<br />
hd.startElement("","","USER",atts);<br />
hd.characters(desc[i].toCharArray(),0,desc[i].length());<br />
hd.endElement("","","USER");<br />
}<br />
hd.endElement("","","USERS");<br />
hd.endDocument();<br />
[...]</p>
<p></code></p>
]]></content:encoded>
			<wfw:commentRss>http://robotics.icstweb.org/java-do-diez/2009/01/07/tutorial-xml-generation-with-java/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
