<?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>Codebreaker &#187; Java</title>
	<atom:link href="http://blog.sumin.us/archives/tag/java/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.sumin.us</link>
	<description>2bc08752a0894eb2c7afb345286e391d</description>
	<lastBuildDate>Wed, 08 Sep 2010 02:15:36 +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>Languages of the Year 2009</title>
		<link>http://blog.sumin.us/archives/1200</link>
		<comments>http://blog.sumin.us/archives/1200#comments</comments>
		<pubDate>Wed, 23 Dec 2009 00:42:44 +0000</pubDate>
		<dc:creator>Sumin</dc:creator>
				<category><![CDATA[general]]></category>
		<category><![CDATA[C++]]></category>
		<category><![CDATA[haskell]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[Javascript]]></category>
		<category><![CDATA[objective-c]]></category>
		<category><![CDATA[PHP]]></category>
		<category><![CDATA[prolog]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.sumin.us/?p=1200</guid>
		<description><![CDATA[It's almost the end of the year 2009. This year is special because I've never dealt with so many languages in a year. Objective C, Python, Java, C++, PHP, JavaScript, Haskell, Prolog, Ruby, C#, and probably more. Some of them were for work, some for school, and others were for my personal projects. I have [...]]]></description>
			<content:encoded><![CDATA[<p>It's almost the end of the year 2009. This year is special because I've never dealt with so many languages in a year. Objective C, Python, Java, C++, PHP, JavaScript, Haskell, Prolog, Ruby, C#, and probably more. Some of them were for work, some for school, and others were for my personal projects. I have plenty of stories for each language, but I'll try to keep them brief.</p>

<h3>Objective C</h3>

<p><a href="http://cqube.mobi">CQube</a> iPhone edition was released back in March, and as you know Objective C is the language you use for iPhone application development. Objective C is a strict superset of C, so it didn't take too much effort to learn. Rather, I spent most of time to learn the Cocoa framework. All those magic keywords like <code>@property</code>, <code>@synthesize</code>, and <code>@dynamic</code> were nice to have.</p>

<h3>Python</h3>

<p>I love Python. I used Python for many different things; from disposable command line utilities to implementation of Apple Push Notification service. I also used this language to conduct a <em>classified operation</em>. After I learned Haskell, which is what I'm going to talk about in a minute, I started enjoying use of higher order functions such as <code>map</code>, <code>reduce</code>, <code>filter</code>, and so on.</p>

<h3>Java</h3>

<p>I also use Java a lot. I built a Java mobile application at my work. I also built a nearest neighbor search engine, an HTTP based real time communication framework, and a Luca compiler. There are probably more, but these are the ones I remember. There are few things that I really wish to have in Java: automatic getter/setter, operator overriding, and delegate. Could someone give me these as a Christmas gift? ;-)</p>

<h3>C++</h3>

<p>To be honest with you, I'm kind of scared of this magic language. I would say it's quite difficult and takes a considerable amount of practice to use this language properly and effectively. Well, in my compiler class, I had to use either C or C++ to implement a Luca interpreter with indirect threading.</p>

<h3>PHP</h3>

<p>I'm not a big fan of this language. Ironically, this is probably one of the top three languages that I spent most time with so far. I had a web application development job over the summer. It was a lot of PHP programming. I also had to build server side components at my current work. I wanted to use Python, but apparently not many people know Python. So, I had stick with whatever language that most people can deal with.</p>

<h3>JavaScript</h3>

<p>You would imagine using JavaScript to manipulate the DOM structure of a web page. But, this is not the only case. I used this language to build a Firefox extension (thanks to <a href="http://groups.google.com/group/ua-developers/web/firefox-extension-development-tutorial---part-1">Justin Samuel's Firefox extension development tutorial</a>). I can't tell you what it is though because it's a part of a classified operation.</p>

<h3>Haskell</h3>

<p>Haskell changed a lot of things in my point of view of programming. All the functional programming features and its imperativeness really blew my mind. Basically it made me a better developer in general. Even though I have no intention to use Haskell in production environment, I will be using things I learned from this language.</p>

<h3>Prolog</h3>

<p>Cody Jorgensen:</p>

<blockquote>
  <p>Why can't I get an element from the god damn list?</p>
</blockquote>

<h3>Ruby</h3>

<p>It was very joyful to learn Ruby as I already know how to use Python. Ruby is very similar to Python in many different aspects as C# is similar to Java. I see blocks and the yield keyword as a giant lambda function, and I kind of like it. One thing I like from this language over Python is that there's <code>end</code> keyword so that you don't have to be super careful about indentation. Because of this, there's no need to make a new template language in web application framework such as Ruby on Rails, whereas it is necessary in Python based frameworks such as Django. Oh, it's also very nice to have built-in regular expression features.</p>

<h3>C&#35;</h3>

<p>We decided to switch from Nokia's Symbian to Microsoft Windows Mobile platform at my work. I was hoping the Java code I've been writing works just fine on the Windows Mobile, but few things didn't really work out well. So, I decided to re-write the whole application in C#, and I did it over the last weekend. I wouldn't be able to make all these happen without Visual Studio's great help. Not to mention I didn't have to re-write all the server side components.</p>
<!-- AdSense Now! V1.83 -->
<!-- Post[count: 2] -->
<div class="adsense adsense-leadout" style="text-align:center;margin: 12px;"><script type="text/javascript"><!--
google_ad_client = "pub-2353453386862167";
/* 468x60, created 10/26/09 */
google_ad_slot = "1252542387";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></div>]]></content:encoded>
			<wfw:commentRss>http://blog.sumin.us/archives/1200/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>VM Argument for UTF-8</title>
		<link>http://blog.sumin.us/archives/695</link>
		<comments>http://blog.sumin.us/archives/695#comments</comments>
		<pubDate>Thu, 20 Dec 2007 07:49:36 +0000</pubDate>
		<dc:creator>Sumin</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.sumin.us/archives/695</guid>
		<description><![CDATA[-Dfile.encoding=UTF-8]]></description>
			<content:encoded><![CDATA[<pre><code>-Dfile.encoding=UTF-8
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.sumin.us/archives/695/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java 동적 클래스 로드</title>
		<link>http://blog.sumin.us/archives/600</link>
		<comments>http://blog.sumin.us/archives/600#comments</comments>
		<pubDate>Sat, 21 Apr 2007 07:24:27 +0000</pubDate>
		<dc:creator>Sumin</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.superwtk.com/archives/600</guid>
		<description><![CDATA[PHP 에선 다음과 같은 다소 황당한 문법도 통한다. $class_name = 'post'; new $class_name($parameters); Java 에도 동적으로 클래스를 로드하는 방법이 있다. 역시 뭔가 조금 딱딱한 느낌이다. abstract class Person { public abstract String toString(); } class Woody extends Person{ @Override public String toString() { return "What's up, man."; } } class Haruhi extends Person { @Override [...]]]></description>
			<content:encoded><![CDATA[<p>PHP 에선 다음과 같은 다소 황당한 문법도 통한다.</p>

<pre><code>$class_name = 'post';
new $class_name($parameters);
</code></pre>

<p>Java 에도 동적으로 클래스를 로드하는 방법이 있다. 역시 뭔가 조금 딱딱한 느낌이다.</p>

<pre><code>abstract class Person {
    public abstract String toString();
}

class Woody extends Person{
    @Override
    public String toString() {
        return "What's up, man.";
    }
}

class Haruhi extends Person {
    @Override
    public String toString() {
        return "Sumin-san, ohayougozaimasu!";
    }
}

public class ClassTest {
    public static void main(String[] args) throws Exception {
        Class c = Class.forName("Woody");
        Person p = (Person)c.newInstance();
        System.out.println(p);

        System.out.println(Class.forName("Haruhi").newInstance());
    }
}
</code></pre>

<p>결과는</p>

<pre><code>What's up, man.
Sumin-san, ohayougozaimasu!
</code></pre>

<p>참고로 <a href="http://java.sun.com/javase/6/docs/api/java/lang/Class.html#forName(java.lang.String)">Class.forName(String className)</a> 가 되돌려주는것은 인스턴스가 아니다. 클래스이다. 실제 인스턴스를 얻기 위해서는 <a href="http://java.sun.com/javase/6/docs/api/java/lang/Class.html#newInstance()">newInstance()</a> 메소드를 호출해야 한다.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sumin.us/archives/600/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>새로운(?) 자바 코딩법을 소개합니다</title>
		<link>http://blog.sumin.us/archives/531</link>
		<comments>http://blog.sumin.us/archives/531#comments</comments>
		<pubDate>Fri, 26 Jan 2007 10:02:26 +0000</pubDate>
		<dc:creator>Sumin</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[unicode]]></category>

		<guid isPermaLink="false">http://blog.superwtk.com/archives/531</guid>
		<description><![CDATA[\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0020\u0020\u0020 \u0063\u006c\u0061\u0073\u0073\u0020\u0020\u0020\u0020\u0020 \u0048\u0065\u006c\u006c\u006f\u0057\u006f\u0072\u006c\u0064 \u0020\u007b\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u000d \u000a\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0020\u0020 \u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0020\u0020 \u0020\u0076\u006f\u0069\u0064\u0020\u0020\u0020\u0020\u0020 \u0020\u006d\u0061\u0069\u006e\u0028\u0020\u0020\u0020\u0020 \u0020\u0053\u0074\u0072\u0069\u006e\u0067\u005b\u005d\u0020 \u0020\u0061\u0072\u0067\u0073\u0029\u0020\u007b\u0020\u0020 \u000d\u000a\u0053\u0079\u0073\u0074\u0065\u006d\u002e\u0020 \u0020\u0020\u006f\u0075\u0074\u002e\u0020\u0020\u0020\u0020 \u0020\u0020\u0070\u0072\u0069\u006e\u0074\u006c\u006e\u0028 \u0020\u0020\u0022\u0048\u0065\u006c\u006c\u006f\u0020\u0022 \u002b\u0020\u0022\u0057\u006f\u0072\u006c\u0064\u0021\u0022 \u0020\u0020\u0029\u003b\u0020\u0020\u0020\u0020\u0020\u0020 \u0020\u000d\u000a\u007d\u000d\u000a\u007d\u000d\u000a\u0020 무슨 코드일까? 실행시켜보면 안다 ;)]]></description>
			<content:encoded><![CDATA[<pre><code>\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0020\u0020\u0020
\u0063\u006c\u0061\u0073\u0073\u0020\u0020\u0020\u0020\u0020
\u0048\u0065\u006c\u006c\u006f\u0057\u006f\u0072\u006c\u0064
\u0020\u007b\u0020\u0020\u0020\u0020\u0020\u0020\u0020\u000d
\u000a\u0070\u0075\u0062\u006c\u0069\u0063\u0020\u0020\u0020
\u0020\u0073\u0074\u0061\u0074\u0069\u0063\u0020\u0020\u0020
\u0020\u0076\u006f\u0069\u0064\u0020\u0020\u0020\u0020\u0020
\u0020\u006d\u0061\u0069\u006e\u0028\u0020\u0020\u0020\u0020
\u0020\u0053\u0074\u0072\u0069\u006e\u0067\u005b\u005d\u0020
\u0020\u0061\u0072\u0067\u0073\u0029\u0020\u007b\u0020\u0020
\u000d\u000a\u0053\u0079\u0073\u0074\u0065\u006d\u002e\u0020
\u0020\u0020\u006f\u0075\u0074\u002e\u0020\u0020\u0020\u0020
\u0020\u0020\u0070\u0072\u0069\u006e\u0074\u006c\u006e\u0028
\u0020\u0020\u0022\u0048\u0065\u006c\u006c\u006f\u0020\u0022
\u002b\u0020\u0022\u0057\u006f\u0072\u006c\u0064\u0021\u0022
\u0020\u0020\u0029\u003b\u0020\u0020\u0020\u0020\u0020\u0020
\u0020\u000d\u000a\u007d\u000d\u000a\u007d\u000d\u000a\u0020
</code></pre>

<p>무슨 코드일까? 실행시켜보면 안다 ;)</p>

<!-- Java Coding with Raw Unicode -->
]]></content:encoded>
			<wfw:commentRss>http://blog.sumin.us/archives/531/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>Can It Be True?</title>
		<link>http://blog.sumin.us/archives/462</link>
		<comments>http://blog.sumin.us/archives/462#comments</comments>
		<pubDate>Sun, 14 Jan 2007 01:38:19 +0000</pubDate>
		<dc:creator>Sumin</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.superwtk.com/archives/462</guid>
		<description><![CDATA[Code Result Why? What the hell is wrong with that? The red one is actually 'L', which means the result is gonna be 155L. I strongly recommend using L instead of l when you represent a number which is a type of Long.]]></description>
			<content:encoded><![CDATA[<h3>Code</h3>

<p><img id="image459" src="/wp-content/uploads/2007/01/818302.png" alt="818302.png" /></p>

<h3>Result</h3>

<p><img id="image460" src="/wp-content/uploads/2007/01/818303.png" alt="818303.png" /></p>

<h3>Why? What the hell is wrong with that?</h3>

<p><img id="image461" src="/wp-content/uploads/2007/01/818304.png" alt="818304.png" /></p>

<p>The red one is actually 'L', which means the result is gonna be <code>155L</code>. I strongly recommend using <code>L</code> instead of <code>l</code> when you represent a number which is a type of <code>Long</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sumin.us/archives/462/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>한글 음절(syllable) 다루기</title>
		<link>http://blog.sumin.us/archives/375</link>
		<comments>http://blog.sumin.us/archives/375#comments</comments>
		<pubDate>Thu, 06 Jul 2006 03:55:13 +0000</pubDate>
		<dc:creator>Sumin</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[한글]]></category>

		<guid isPermaLink="false">http://blog.superwtk.com/archives/375</guid>
		<description><![CDATA[서론 음절은 하나 또는 그 이상의 말소리로 이루어져 독자적으로 발음되는 가장 작은 단위이다. 또 다른 말로는 '소리마디', 영어로는 syllable 이라고 한다. 한글의 음절은 초성, 중성, 종성으로 이루어진다. 초성과 중성은 반드시 있어야 하지만 종성은 없어도 음절을 구성하는데 지장이 없다. 더 자세히 들어가면 나의 국문학적 무지가 탄로날지도 모르니 서론은 여기서 그만 하도록 하겠다. 본론 간단하게 음절을 다루는 [...]]]></description>
			<content:encoded><![CDATA[<h1>서론</h1>

<p>음절은 하나 또는 그 이상의 말소리로 이루어져 독자적으로 발음되는 가장 작은 단위이다. 또 다른 말로는 '소리마디', 영어로는 syllable 이라고 한다. 한글의 음절은 초성, 중성, 종성으로 이루어진다. 초성과 중성은 반드시 있어야 하지만 종성은 없어도 음절을 구성하는데 지장이 없다. 더 자세히 들어가면 나의 국문학적 무지가 탄로날지도 모르니 서론은 여기서 그만 하도록 하겠다.</p>

<h1>본론</h1>

<p>간단하게 음절을 다루는 클래스, Syllable 을 작성하기로 했다. 내부적으로 초성, 중성, 종성을 분리하여 저장하고 있으며, 몇 가지 편리한 메소드를 제공한다.</p>

<p>Syllable 클래스를 작성하기 시작한지 얼마 지나지 않아서 문제에 봉착하게 되었다. 키보드에서 'ㄱ' 을 눌러서 타이핑된 글자의 코드는 <code>0x3131</code> 이지만, unicode specifications 에 나와있는 초성의 'ㄱ'은 <code>0x1100</code>, 종성의 'ㄱ'은 <code>0x11A8</code> 이다. 이 문제를 해결하기 위해 외부적으로는 <code>0x3131</code> 과 <code>0x1100</code> 이 모두 허용되도록 하고, 내부적으로는 specifications 에 나와있는 코드를 쓰기로 결정했다.</p>

<p>음절을 만드는 방법은 다음의 3가지가 있다.</p>

<h4>방법 1</h4>

<p>빈 음절 인스턴스를 만든 후, 초성, 중성, 종성을 따로 집어넣는다.</p>

<pre><code>Syllable s1 = new Syllable();
s1.setChoSeong('ㅂ');
s1.setJungSeong('ㅡ');
s1.setJongSeong('ㄹ');
</code></pre>

<h4>방법 2</h4>

<p>방법 1과 비슷하다. 단지 생성자가 그 일을 대신할 뿐이다.</p>

<pre><code>Syllable s2 = new Syllable('ㄹ', 'ㅗ');
</code></pre>

<h4>방법 3</h4>

<p>마지막으로, 생성자에 완전한 음절을 집어넣는 방법이 있다.</p>

<pre><code>Syllable s3 = new Syllable('그');
</code></pre>

<h4>예제</h4>

<pre><code>System.out.print(s1);
System.out.print(s2);
System.out.print(s3);
</code></pre>

<p>실행 결과는</p>

<pre><code>블로그
</code></pre>

<p>전체 코드를 공개하면 좋겠지만, 안타깝게도 Syllable 클래스의 소스코드는 당분간 공개하지 않기로 결정했다. 대신, 프로토타입 정도는 공개한다.</p>

<pre><code>public class Syllable {

    private char choSeong;
    private char jungSeong;
    private char jongSeong;

    public Syllable();
    public Syllable(char syllable);
    public Syllable(char choSeong, char jungSeong);
    public Syllable(char choSeong, char jungSeong, char jongSeong);

    public void setChoSeong(char choSeong);
    public char getChoSeong();
    public void setJungSeong(char jungSeong);
    public char getJungSeong();
    public void setJongSeong(char jongSeong);
    public char getJongSeong();

    public String toString();

    public static boolean isSyllable(char character);
    public static char[] split(char syllable);
    public static char build(char choSeong, char jungSeong, char jongSeong);
}
</code></pre>

<h1>참고 자료</h1>

<ul>
<li><a href="http://web.edunet4u.net/~han0416/%ED%95%98%EB%93%9C%EC%9B%A8%EC%96%B4%20%EA%B0%95%EC%A2%8C/chapter2/uni_code2_iso.htm">유니코드 (구원의 여신 등장?)</a></li>
<li><a href="http://en.wikipedia.org/wiki/Hangul">http://en.wikipedia.org/wiki/Hangul</a></li>
<li><a href="http://www.unicode.org/charts/PDF/U1100.pdf">http://www.unicode.org/charts/PDF/U1100.pdf</a></li>
<li><a href="http://www.unicode.org/charts/PDF/UAC00.pdf">http://www.unicode.org/charts/PDF/UAC00.pdf</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.sumin.us/archives/375/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>한글 자소 분리</title>
		<link>http://blog.sumin.us/archives/353</link>
		<comments>http://blog.sumin.us/archives/353#comments</comments>
		<pubDate>Wed, 28 Jun 2006 06:45:06 +0000</pubDate>
		<dc:creator>Sumin</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[한글]]></category>

		<guid isPermaLink="false">http://blog.superwtk.com/archives/353</guid>
		<description><![CDATA[레몬향기혜성님이 쓴 포스트를 보고 Java 로 conversion 해봤다. 학교 도서관 컴퓨터로 프로그래밍 하는 일은 그다지 유쾌한 일이 아니다. 개발도구가 설치되어있지 않음은 물론이고 Administrator Privilege 도 없어서 소프트웨어를 마음대로 설치할 수 없다. 그래도 다행인것은 Eclipse는 설치하지 않고 실행이 가능하다는 점과, Mac 에서는 Netbeans 도 설치하지 않고 실행할 수 있다는 점이다. 아무튼, 이 클래스는 도서관에 있는 Power [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://mwultong.blogspot.com">레몬향기혜성</a>님이 쓴 <a href="http://mwultong.blogspot.com/2006/03/perl.html" title="[Perl/펄] 한글 자소 분리: '똠방각하'를 'ㄸㅗㅁㅂㅏㅇㄱㅏㄱㅎㅏ'로 자동 변환">포스트</a>를 보고 Java 로 conversion 해봤다.</p>

<p>학교 도서관 컴퓨터로 프로그래밍 하는 일은 그다지 유쾌한 일이 아니다. 개발도구가 설치되어있지 않음은 물론이고 Administrator Privilege 도 없어서 소프트웨어를 마음대로 설치할 수 없다. 그래도 다행인것은 Eclipse는 설치하지 않고 실행이 가능하다는 점과, Mac 에서는 Netbeans 도 설치하지 않고 실행할 수 있다는 점이다.</p>

<p>아무튼, 이 클래스는 도서관에 있는 Power Mac 으로 힘들게;; 작성했다. 인코딩은 UTF-8 으로 설정해야 된다.</p>

<pre><code>/*
 * Jaso.java
 *
 * Created on June 27, 2006, 3:12 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

import java.util.Vector;

/**
 *
 * @author guest
 */
public class Jaso {

    public static char[] ChoSeong = { 0x3131, 0x3132, 0x3134, 0x3137, 0x3138,
            0x3139, 0x3141, 0x3142, 0x3143, 0x3145, 0x3146, 0x3147, 0x3148,
            0x3149, 0x314a, 0x314b, 0x314c, 0x314d, 0x314e };
    public static char[] JungSeong = { 0x314f, 0x3150, 0x3151, 0x3152, 0x3153,
            0x3154, 0x3155, 0x3156, 0x3157, 0x3158, 0x3159, 0x315a, 0x315b,
            0x315c, 0x315d, 0x315e, 0x315f, 0x3160, 0x3161, 0x3162, 0x3163 };
    public static char[] JongSeong = { 0x0000, 0x3131, 0x3132, 0x3133, 0x3134,
            0x3135, 0x3136, 0x3137, 0x3139, 0x313a, 0x313b, 0x313c, 0x313d,
            0x313e, 0x313f, 0x3140, 0x3141, 0x3142, 0x3144, 0x3145, 0x3146,
            0x3147, 0x3148, 0x314a, 0x314b, 0x314c, 0x314d, 0x314e };

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            char[] chars = "대한민주주의공화국".toCharArray();
            Vector&lt;character&gt; v = new Vector&lt;character&gt;();

            for (int i = 0; i &lt; chars.length; i++) {
                if (chars[i] &gt;= 0xAC00 &amp;&amp; chars[i] &lt;= 0xD7A3) {
                    int i1, i2, i3;

                    i3 = chars[i] - 0xAC00;
                    i1 = i3 / (21 * 28);
                    i3 = i3 % (21 * 28);
                    i2 = i3 / 28;
                    i3 = i3 % 28;

                    v.add(ChoSeong[i1]);
                    v.add(JungSeong[i2]);
                    if (i3 != 0x0000)
                        v.add(JongSeong[i3]);
                }
                else {
                    v.add(chars[i]);
                }
            }

            System.out.println(v);
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }

}
</code></pre>

<p>결과는 다음과 같다.</p>

<pre><code>[ㄷ, ㅐ, ㅎ, ㅏ, ㄴ, ㅁ, ㅣ, ㄴ, ㅈ, ㅜ, ㅈ, ㅜ, ㅇ, ㅢ, ㄱ, ㅗ, ㅇ, ㅎ, ㅘ, ㄱ, ㅜ, ㄱ]
</code></pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.sumin.us/archives/353/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>Exccesive Constants</title>
		<link>http://blog.sumin.us/archives/310</link>
		<comments>http://blog.sumin.us/archives/310#comments</comments>
		<pubDate>Sat, 03 Jun 2006 21:02:56 +0000</pubDate>
		<dc:creator>Sumin</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.superwtk.com/archives/310</guid>
		<description><![CDATA[서론 Java 에서는 final 키워드가 붙은 변수가 어떻게 처리될까요. 이것에 관련된 간단한 실험을 한가지 해보겠습니다. Justin 의 identification Justin 의 나이, 신원, 지역을 저장해놓은 클래스입니다. import java.util.Locale; public class Justin { public final static int age = 18; public final static String identification = "I'm Justin"; public final static Locale locale = new Locale("en-US"); } [...]]]></description>
			<content:encoded><![CDATA[<h1>서론</h1>

<p>Java 에서는 final 키워드가 붙은 변수가 어떻게 처리될까요. 이것에 관련된 간단한 실험을 한가지 해보겠습니다.</p>

<h1>Justin 의 identification</h1>

<p>Justin 의 나이, 신원, 지역을 저장해놓은 클래스입니다.</p>

<pre><code>import java.util.Locale;

public class Justin {
    public final static int age = 18;
    public final static String identification = "I'm Justin";
    public final static Locale locale = new Locale("en-US");
}
</code></pre>

<p>Justin 클래스의 각 상수들을 출력하는 클래스입니다.</p>

<pre><code>public class Test {
    public static void main(String[] args) {
        System.out.println(Justin.age);
        System.out.println(Justin.identification);
        System.out.println(Justin.locale);
    }
}
</code></pre>

<p>실행 결과는 당연히</p>

<pre><code>18
I'm Justin
en-us
</code></pre>

<p>입니다. 자, 그럼 이제 Justin 클래스를 약간 수정해보겠습니다.</p>

<pre><code>public class Justin {
    public final static int age = 21;
    public final static String identification = "I'm not Justin";
    public final static Locale locale = new Locale("ko-KR");
}
</code></pre>

<p>Justin 클래스는 컴파일 하고, Test 클래스는 다시 컴파일하지 않고 그대로 실행합니다. 실행 결과는</p>

<pre><code>18
I'm Justin
ko-kr
</code></pre>

<p>입니다. locale 의 값은 의도한대로 바뀌었지만, 나머지 값들은 그대로입니다. 어찌된 일일까요.</p>

<h1>결론</h1>

<p>위 실험 결과를 토대로 다음과 같은 결론을 도출해낼 수 있습니다. <strong>"final 키워드가 붙은 primitive 와 String 형식의 변수는 컴파일타임에 해당 클래스에서 <acronym title="hard coding 된">상수</acronym>로 치환된다"</strong> 다른 말로 해서,</p>

<pre><code>public class Test {
    public static void main(String[] args) {
        System.out.println(Justin.age);
        System.out.println(Justin.identification);
        System.out.println(Justin.locale);
    }
}
</code></pre>

<p>이 코드는</p>

<pre><code>public class Test {
    public static void main(String[] args) {
        System.out.println(18);
        System.out.println("I'm Justin");
        System.out.println(Justin.locale);
    }
}
</code></pre>

<p>와 똑같은 효과를 가집니다. Justin 클래스의 변경사항을 Test 클래스에 반영시키려면 Test 클래스를 다시 컴파일해야 합니다.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sumin.us/archives/310/feed</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Iterator 패턴에 관한 고찰</title>
		<link>http://blog.sumin.us/archives/306</link>
		<comments>http://blog.sumin.us/archives/306#comments</comments>
		<pubDate>Wed, 31 May 2006 08:33:07 +0000</pubDate>
		<dc:creator>Sumin</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[design pattern]]></category>
		<category><![CDATA[iterator]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.superwtk.com/archives/306</guid>
		<description><![CDATA[서론 정말 뜨겁습니다. 그리고 건조합니다. (사실 글 내용과 전혀 상관 없습니다-_-a) LinkedList 탐색 Java 로 프로그래밍을 처음 해보는 초보자에게 이 문서를 주면서 LinkedList 의 모든 원소를 출력하는 프로그램을 작성하라는 숙제를 내주면 아마도 다음과 같이 작성할 것입니다. LinkedList&#60;integer&#62; list = new LinkedList&#60;integer&#62;(); list.add(34); list.add(72); list.add(59); for(int i=0; i&#60;list.size(); i++) { System.out.println(list.get(i)); } 위의 코드는 당장 어떤 [...]]]></description>
			<content:encoded><![CDATA[<h1>서론</h1>

<p><img src="/wp-content/uploads/2006/05/weather.png" alt="weather.png" /></p>

<p>정말 뜨겁습니다. 그리고 건조합니다.
(사실 글 내용과 전혀 상관 없습니다-_-a)</p>

<h1>LinkedList 탐색</h1>

<p>Java 로 프로그래밍을 처음 해보는 초보자에게 <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/LinkedList.html">이 문서</a>를 주면서 LinkedList 의 모든 원소를 출력하는 프로그램을 작성하라는 숙제를 내주면 아마도 다음과 같이 작성할 것입니다.</p>

<pre><code>LinkedList&lt;integer&gt; list = new LinkedList&lt;integer&gt;();
list.add(34);
list.add(72);
list.add(59);

for(int i=0; i&lt;list.size(); i++) {
    System.out.println(list.get(i));
}
</code></pre>

<p>위의 코드는 당장 어떤 문제가 있는 코드는 아닙니다. 문법적 오류도 없으며, 의도한 결과가 나옵니다. 하지만 소프트웨어의 유지보수 측면에서 보면 그다지 깔끔한 구현 방법은 아닙니다. 만약 LinkedList 대신 <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Hashtable.html">Hashtable</a> 을 사용하라는 요구사항이 생긴다면 어떻게 될까요. 데이터를 삽입하는 부분은 그렇다 치더라도, 데이터를 출력하는 부분의 코드도 모두 바꿔야 합니다. 물론 여기서 예로 든 상황은 약간 억지스러워보일 수도 있고, 심각한 수준의 문제도 아닙니다. 하지만, 소프트웨어를 개발하다보면 이렇게 요구사항에 유연하게 대처하기 힘든 상황이 빈번히 발생합니다.</p>

<h1>Iterator 패턴</h1>

<p><a href="http://www.allapplabs.com/java_design_patterns/iterator_pattern.htm">원문</a>에 따르면, Iterator 패턴은 내부 구현에 대한 이해 없이 자료의 집합체(List, Stack 등)를 탐색할 수 있도록 해주는 것이라고 합니다.</p>

<blockquote>
  <p>The Iterator pattern is one, which allows you to navigate through a collection of data using a common interface without knowing about the underlying implementation.</p>
</blockquote>

<h1>Java 에서의 Iterator 패턴</h1>

<p>java.util.Collection 인터페이스에는 iterator 메소드가 있습니다.</p>

<blockquote>
  <p><code>Iterator&lt;e&gt; iterator()</code>
  Returns an iterator over the elements in this collection. There are no guarantees concerning the order in which the elements are returned (unless this collection is an instance of some class that provides a guarantee).</p>
</blockquote>

<p>각 Collection 에서 적당한 Iterator 의 인스턴스를 반환하도록 되어있습니다. 예를 들면, Vector 클래스의 iterator() 메소드는 Vector 를 순차적으로 탐색할 수 있는 Iterator 의 인스턴스를 반환합니다. 그렇게 함으로써</p>

<pre><code>Iterator i = list.iterator();
while(i.hasNext()) {
    System.out.println(i.next());
}
</code></pre>

<p>와 같은 코드 작성이 가능한 것입니다. Vector 클래스를 사용하는 개발자는 Vector 클래스의 내부 구현이 어떻게 되어있는지, 어떻게 탐색해야 되는지에 대해서 전혀 알 필요가 없습니다. 오직 Iterator 의 hasNext 와 next 메소드의 사용법만 알면 Vector 클래스 탐색이 가능합니다.</p>

<p>iterator 메소드는 Collection 작성자에 의해서 구현됩니다. 바꿔 말하면, Collection 을 만드는 개발자 마음대로 탐색 방법을 결정할 수 있다는 뜻입니다. 만약 여러분이 <a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/AbstractList.html">java.util.AbstractList</a>를 상속받아서 MyVector 라는 클래스를 구현한다고 가정한다면, iterator 메소드를 어떻게 작성하느냐에 따라서 탐색 방법이 달라질 수 있습니다. 역순으로 탐색하는것도 가능하고, Collection 의 <acronym title="element">요소</acronym>를 한칸씩 건너서 탐색하는것도 가능합니다. 다시 한 번 간단히 정리하자면, iterator 의 구현은 구현하는 사람 마음대로입니다.</p>

<p>Iterator 는 실제적 구현체를 갖지 않는 인터페이스이므로, 다음과 같이 Iterator 의 인스턴스를 생성하는것은 불가능합니다.</p>

<pre><code>Iterator i = new Iterator(); // impossible
</code></pre>

<p>각 Collection 에서 적절한 Iterator 를 얻어와야 사용이 가능합니다.</p>

<pre><code>Vector v = new Vector();
Iterator i = v.iterator();
</code></pre>

<p>이렇게 말입니다.</p>

<h1>Iterator 이용</h1>

<p>먼저, 리스트의 내용을 출력하는 간단한 프로그램을 작성해보겠습니다.</p>

<pre><code>List&lt;string&gt; list = new LinkedList&lt;string&gt;();
list.add("Windows XP");
list.add("Gentoo Linux");
list.add("Solaris 10");

Iterator&lt;string&gt; i = list.iterator();
while(i.hasNext()) {
    System.out.println(i.next());
}
</code></pre>

<p>첫번째 예제와 다른점은 for 이 아닌 while loop 과 Iterator 을 사용한다는 것입니다.</p>

<pre><code>List&lt;string&gt; list = new Vector&lt;string&gt;();
list.add("Windows XP");
list.add("Gentoo Linux");
list.add("Solaris 10");

Iterator&lt;string&gt; i = list.iterator();
while(i.hasNext()) {
    System.out.println(i.next());
}
</code></pre>

<p>이번엔 LinkedList 가 아닌 Vector 를 사용했습니다. 하지만 데이터를 출력하는 부분은 똑같습니다.</p>

<pre><code>HashMap&lt;integer, String&gt; map = new HashMap&lt;integer, String&gt;();
map.put(1, "Windows XP");
map.put(2, "Gentoo Linux");
map.put(3, "Solaris 10");

Iterator&lt;string&gt; i = map.values().iterator();
while(i.hasNext()) {
    System.out.println(i.next());
}
</code></pre>

<p>이번엔 HashMap 을 사용했습니다. HashMap 은 위에서 사용했던 LinkedList 나 Vector 과는 다른 종류의 Collection 입니다. HashMap 은 크게 Map 으로 분류되고, LinkedList 와 Vector 는 List 로 분류됩니다. 하지만 위에서 볼 수 있듯이 각 Collection 이 가지고 있는 자료를 출력하는 코드의 모양엔 차이가 없습니다.</p>

<h1>맺음말</h1>

<p>문서가 아직 미완성인듯 합니다-_-a</p>

<h1>참고 자료</h1>

<ul>
<li><a href="http://www.allapplabs.com/java_design_patterns/iterator_pattern.htm">http://www.allapplabs.com/java_design_patterns/iterator_pattern.htm</a></li>
<li><a href="http://java.sun.com/j2se/1.5.0/docs/api/index.html">http://java.sun.com/j2se/1.5.0/docs/api/index.html</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.sumin.us/archives/306/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>간단한 자바 소켓 프로그래밍</title>
		<link>http://blog.sumin.us/archives/303</link>
		<comments>http://blog.sumin.us/archives/303#comments</comments>
		<pubDate>Fri, 26 May 2006 21:09:52 +0000</pubDate>
		<dc:creator>Sumin</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[socket]]></category>
		<category><![CDATA[stream]]></category>

		<guid isPermaLink="false">http://blog.superwtk.com/archives/303</guid>
		<description><![CDATA[서론 이 글은 http://0pen.us 에 제가 썼던 글을 재구성하여 작성한 것입니다. 코드 먼저 간단한 예제를 보여드리겠습니다. 프로그램은 크게 두 부분으로 나뉩니다. 하나는 일을 간단하게 처리할 수 있도록 만들어놓은 래핑(wrapping) 클래스이고, 다른 하나는 그것을 이용하는 메인 클래스입니다. 래핑 클래스 /* * Worker.java * * Created on May 23, 2006, 10:36 AM * * To change this [...]]]></description>
			<content:encoded><![CDATA[<h1>서론</h1>

<p>이 글은 <a href="http://0pen.us">http://0pen.us</a> 에 <a href="http://0pen.us/Forum/programforum/99">제가 썼던 글</a>을 재구성하여 작성한 것입니다.</p>

<h1>코드</h1>

<p>먼저 간단한 예제를 보여드리겠습니다. 프로그램은 크게 두 부분으로 나뉩니다. 하나는 일을 간단하게 처리할 수 있도록 만들어놓은 래핑(wrapping) 클래스이고, 다른 하나는 그것을 이용하는 메인 클래스입니다.</p>

<h2>래핑 클래스</h2>

<pre><code>/*
 * Worker.java
 *
 * Created on May 23, 2006, 10:36 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package app;

import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.IOException;
import java.net.InetAddress;
import java.net.Socket;
import java.net.UnknownHostException;

/**
 *
 * @author superwtk
 */
public class Worker {

    private Socket socket;
    private BufferedInputStream bis;
    private BufferedOutputStream bos;

    /** Creates a new instance of Worker */
    public Worker() {
        socket = null;
        bis = null;
        bos = null;
    }

    public void connect(String host, int port) throws UnknownHostException, IOException {
        socket = new Socket(InetAddress.getByName(host), port);

        bis = new BufferedInputStream(socket.getInputStream());
        bos = new BufferedOutputStream(socket.getOutputStream());
    }

    public void connect(String host, int port, int localPort) throws UnknownHostException, IOException {
        socket = new Socket(InetAddress.getByName(host), port, InetAddress.getLocalHost(), localPort);
    }

    public void sendMessage(String message) throws IOException {
        bos.write(message.getBytes());
        bos.flush();
    }

    public String receiveMessage() throws IOException {
        byte[] buf = new byte[4096];
        StringBuffer strbuf = new StringBuffer(4096);

        int read = 0;
        while((read = bis.read(buf)) &gt; 0) {
            strbuf.append(new String(buf, 0, read));
        }

        return new String(strbuf);
    }

    public void disconnect() throws IOException {
        bis.close();
        bos.close();
        socket.close();
    }

}
</code></pre>

<h2>메인 클래스</h2>

<pre><code>/*
 * Main.java
 *
 * Created on May 23, 2006, 10:35 AM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package app;

/**
 *
 * @author superwtk
 */
public class Main {

    /** Creates a new instance of Main */
    public Main() {
    }

    /**
     * @param args the command line arguments
     */
    public static void main(String[] args) {
        try {
            Worker w = new Worker();
            w.connect("0pen.us", 80);

            StringBuffer message = new StringBuffer();
            message.append("GET /Forum/ HTTP/1.1\r\n");
            message.append("Host: 0pen.us\r\n");
            message.append("\r\n");

            w.sendMessage(new String(message));
            System.out.println(w.receiveMessage());

            w.disconnect();
        }
        catch(Exception e) {
            e.printStackTrace();
        }
    }

}
</code></pre>

<h1>결과</h1>

<p>http://0pne.us/Forum/ 의 HTML 코드가 출력됩니다.</p>

<h1>GUI Version</h1>

<p><img src="/wp-content/uploads/2006/05/socket.png" alt="socket.png" /></p>

<h1>그런데 스트림은 왜 쓰는것일까요?</h1>

<p>자바에서 소켓을 이용한 통신은 일반적으로</p>

<ol>
<li>소켓을 생성</li>
<li>연결 확립</li>
<li>Input/Output 스트림 얻어오기</li>
<li>스트림을 통해서 데이터 주고 받기</li>
<li>스트림 닫기, 소켓 닫기</li>
</ol>

<p>와 같은 순서로 이루어집니다.</p>

<pre><code>Socket s = new Socket( /*생략*/ );
InputStream is = s.getInputStream();
OutputStream os = s.getOutputStream();

byte[] buf = new byte[1024];
is.read(buf);
os.write("hooray~".getBytes());

is.close()
os.close();
s.close();
</code></pre>

<p>물론 필요에 따라 순서를 바꿀 수도 있습니다. 그럼 소켓을 이용해서 직접 데이터를 주고받는 편한 방법을 놔두고 자바 소켓은 굳이 스트림을 이용해서 통신을 할까요?</p>

<pre><code>Socket s = new Socket( /*생략*/ );

byte[] buf = new byte[1024];
s.recv(buf);
s.send("hooray~".getBytes());

s.close();
</code></pre>

<p>스트림을 쓰지 않고 위와 같이 하면 좋을텐데 말입니다. 이건 유닉스나, 유닉스 구성하는 대부분의 소프트웨어를 만들어낸 C언어에서 가져온 개념이라고 생각됩니다.</p>

<p>유닉스에서는 모든 것이 파일로 표현됩니다. 일반적으로 말하는 (디스크 상의) 파일도 파일이고, 키보드, 마우스, 프린터, 스캐너 등 각종 디바이스들도 파일로 표현됩니다. 해당 파일에 뭔가를 쓰면 그 파일로 데이터가 출력됩니다. 예를 들면, 프린터를 나타내는 파일에 데이터를 쓰면 프린터로 해당 데이터가 출력되는 식입니다. 물론 마우스나 키보드를 나타내는 파일에 데이터를 쓸 수는 없겠지요.</p>

<p>stdio.h 에는 다음과 같은 함수가 있습니다.</p>

<pre><code>ssize_t write(int fildes, const void *buf, size_t nbyte);
</code></pre>

<p>이 함수를 이용하면 어디든지 원하는 곳에 원하는 데이터를 쓸 수가 있습니다. 예를 들어서,</p>

<pre><code>write(fileno(stdout), "I'm your father\n", 16);
</code></pre>

<p>와 같이 하면 stdout (표준출력) 을 통해서 해당 데이터를 출력합니다. 이번엔 로컬 디스크에 파일을 작성해보겠습니다.</p>

<pre><code>FILE* file = fopen("output.txt", "w");
write(fileno(file), "I'm your father", 16);
</code></pre>

<p>이번엔 소켓을 이용해서 데이터를 출력(네트워크를 통해서 송출)해보겠습니다.</p>

<pre><code>int sock = socket(AF_INET, SOCK_STREAM, 0);
//...(생략)
write(sock, "I'm your father", 16);
</code></pre>

<p>write 함수의 코드는 (거의) 똑같습니다. 하지만 완전히 다른 일을 하게 되죠. 하나는 표준입출력을 통해서 데이터를 출력하고, 다른 하나는 로컬 디스크에 출력을 하게 되고, 또 다른 하나는 네트워크를 통해서 데이터를 보내게 됩니다.</p>

<p>자바의 스트림도 이와 비슷한 개념입니다. FileInputStream, FileOutputStream, DataInputStream, DataOutputStream, BufferedInputStream, BufferedOutputStream, CipherInputStream, CipherOutputStream 등 수많은 클래스의 부모 클래스가 되는 InputStream 과 OutpuStream 클래스가 있습니다. 일반적인 경우, InputStream 의 read() 메소드와 OutputStream 의 write() 메소드만 있으면 입출력하는데 부족함이 없습니다. 수많은 종류의 스트림들은 이 부모 스트림들을 확장해서 특수한 목적에 사용되도록 특수한 성질을 부여한 스트림입니다. 예를 들어, Buffered{Input|Output}Stream 은 내부적으로 적절한 버퍼링을 하여 입출력을 효율적으로 하도록 도와줍니다. Cipher{Input|Output}Stream 은 객체 암호문을 쉽고 편하게 입출력 하도록 도와줍니다.</p>

<p>그럼 자바에서 유닉스의 <acronym title="File Descriptor">파일 디스크립터</acronym>와 같은 역할을 하는것은 무엇일까요. 각각의 InputStream 과 OutputStream 의 인스턴스들입니다. System.out 은 C의 stdout 이라고 봐도 무방할듯 합니다. 자바를 한번이라도 접해본 사람은 다음과 같은 코드를 본 적이 있을것입니다.</p>

<pre><code>System.out.println("Hello World!");
</code></pre>

<p>이것은 다음의 코드와 같은 효과를 가집니다.</p>

<pre><code>PrintStream ps = System.out;
ps.println("Hello World!");
</code></pre>

<p>물론 다음과 같은 코드도 가능합니다.</p>

<pre><code>OutputStream os = System.out;
os.write("I'm your father".getBytes());
</code></pre>

<p>System.out 의 out 은 java.io.PrintStream 의 인스턴스로, java.lang.System 클래스에 static 멤버로 선언되어 있습니다. 만약 로컬 디스크에 파일을 쓰고 싶으면 다음과 같이 하면 됩니다.</p>

<pre><code>OutputStream os = new FileOutputStream(new File("output.txt"));
os.write("I'm your father".getBytes());
</code></pre>

<p>네트워크를 통해서 내보내고 싶다면 다음과 같이 하면 되겠죠.</p>

<pre><code>Socket socket = new Socket(InetAddress.getByName("somewhere"), port);
OutputStream os = socket.getOutputStream();
os.write("I'm your father".getBytes());
</code></pre>

<p>각 에제의 os.write() 코드는 완전히 똑같지만, 완전히 다른 결과를 가져옵니다. 스트림을 잘 이용하면 인생이 편해집니다.</p>

<!-- java socket programming -->
]]></content:encoded>
			<wfw:commentRss>http://blog.sumin.us/archives/303/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>JavaBeans</title>
		<link>http://blog.sumin.us/archives/301</link>
		<comments>http://blog.sumin.us/archives/301#comments</comments>
		<pubDate>Tue, 23 May 2006 00:39:50 +0000</pubDate>
		<dc:creator>Sumin</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.superwtk.com/archives/301</guid>
		<description><![CDATA[What are JavaBeans? JavaBeans are software components written in the Java programming language. Well, this kind of explanation probably would not be helpful. How to use JavaBeans? Here's a simple example. beans/Bean.java /** * * @author superwtk */ public class Bean { private String name; /** Creates a new instance of Bean */ public Bean() [...]]]></description>
			<content:encoded><![CDATA[<h1>What are JavaBeans?</h1>

<p>JavaBeans are software components written in the Java programming language. Well, this kind of explanation probably would not be helpful.</p>

<h1>How to use JavaBeans?</h1>

<p>Here's a simple example.</p>

<h6>beans/Bean.java</h6>

<pre><code>/**
 *
 * @author superwtk
 */
public class Bean {

    private String name;

    /** Creates a new instance of Bean */
    public Bean() {
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
</code></pre>

<h6>bean.jsp</h6>

<pre><code>&lt;%@page contentType="text/html"%&gt;
&lt;%@page pageEncoding="UTF-8"%&gt;
&lt;%@taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%&gt;
&lt;!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"&gt;
&lt;html&gt;
  &lt;head&gt;
    &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
    &lt;title&gt;JSP Page&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;jsp:useBean id="bean" class="beans.Bean"&gt;
      &lt;jsp:setProperty name="bean" property="name" value="An example of Bean" /&gt;
    &lt;/jsp:useBean&gt;

    &lt;p&gt;
      With JSTL:&lt;br /&gt;
      &lt;c:out value="Name: ${bean.name}" /&gt;
    &lt;/p&gt;

    &lt;p&gt;
      With scriptlet:&lt;br /&gt;
      &lt;%
        out.println("Name: " + bean.getName());
      %&gt;
    &lt;/p&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p>The following bunch of code</p>

<pre><code>&lt;jsp:useBean id="bean" class="beans.Bean"&gt;
  &lt;jsp:setProperty name="bean" property="name"
   value="An example of Bean" /&gt;
&lt;/jsp:useBean&gt;
</code></pre>

<p>has the same effect with</p>

<pre><code>beans.Bean bean = new beans.Bean();
bean.setName("An example of Bean");
</code></pre>

<p>For getting more information, refer to:</p>

<ul>
<li><a href="http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPBeans4.html#64054">http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPBeans4.html#64054</a></li>
<li><a href="http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPBeans5.html#66188">http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPBeans5.html#66188</a></li>
<li><a href="http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPBeans6.html#62111">http://java.sun.com/j2ee/tutorial/1_3-fcs/doc/JSPBeans6.html#62111</a></li>
</ul>

<h1>References</h1>

<ul>
<li><a href="http://en.wikipedia.org/wiki/Java_Beans">http://en.wikipedia.org/wiki/Java_Beans</a></li>
<li>My brain
</ul></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.sumin.us/archives/301/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convert from java.util.Date to java.sql.Date</title>
		<link>http://blog.sumin.us/archives/300</link>
		<comments>http://blog.sumin.us/archives/300#comments</comments>
		<pubDate>Mon, 22 May 2006 06:05:40 +0000</pubDate>
		<dc:creator>Sumin</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[sql]]></category>

		<guid isPermaLink="false">http://blog.superwtk.com/archives/300</guid>
		<description><![CDATA[Content If you try to do like: Calendar cal = Calendar.getInstance(); java.util.Date uDate = cal.getTime(); java.sql.Date sDate = (java.sql.Date) uDate; You will obtain a cast exception. Instead, you can do like: Calendar cal = Calendar.getInstance(); java.util.Date uDate = cal.getTime(); java.sql.Date sDate = new java.sql.Date(uDate.getTime()); References http://www.dbforums.com/t1100948.html http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Date.html http://java.sun.com/j2se/1.5.0/docs/api/java/util/Date.html]]></description>
			<content:encoded><![CDATA[<h1>Content</h1>

<p>If you try to do like:</p>

<pre><code>Calendar cal = Calendar.getInstance();
java.util.Date uDate = cal.getTime();
java.sql.Date sDate = (java.sql.Date) uDate;
</code></pre>

<p>You will obtain a cast exception. Instead, you can do like:</p>

<pre><code>Calendar cal = Calendar.getInstance();
java.util.Date uDate = cal.getTime();
java.sql.Date sDate = new java.sql.Date(uDate.getTime());
</code></pre>

<h1>References</h1>

<ul>
<li><a href="http://www.dbforums.com/t1100948.html">http://www.dbforums.com/t1100948.html</a></li>
<li><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Date.html">http://java.sun.com/j2se/1.5.0/docs/api/java/sql/Date.html</a></li>
<li><a href="http://java.sun.com/j2se/1.5.0/docs/api/java/util/Date.html">http://java.sun.com/j2se/1.5.0/docs/api/java/util/Date.html</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.sumin.us/archives/300/feed</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Top 10 Java Lies</title>
		<link>http://blog.sumin.us/archives/247</link>
		<comments>http://blog.sumin.us/archives/247#comments</comments>
		<pubDate>Sat, 29 Apr 2006 01:01:15 +0000</pubDate>
		<dc:creator>Sumin</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.superwtk.com/archives/247</guid>
		<description><![CDATA[The original post says: Here are the top ten Java lies I have heard over the years. Feel free to add yours in the comments. Enjoy! Java is slow Java is dying / dead Java is not free Java sources are not available / documented J2EE is required for enterprise development Applets are unusable / [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://blog.taragana.com/index.php/archive/top-10-java-lies/">The original post</a> says:</p>

<blockquote>
  <p>Here are the top ten Java lies I have heard over the years. Feel free to add yours in the comments. Enjoy!</p>
  
  <ul>
  <li>Java is slow</li>
  <li>Java is dying / dead</li>
  <li>Java is not free</li>
  <li>Java sources are not available / documented</li>
  <li>J2EE is required for enterprise development</li>
  <li>Applets are unusable / slow / dead</li>
  <li>To learn Java learn Ruby / C</li>
  <li>Java is hard to learn</li>
  <li>C / C++ / PHP (take your pick) is the leading language, Java is far behind</li>
  <li>"The programmers you'll be able to hire to work on a Java project won't be as smart as the ones you could get to work on a project written in Python" by noted Java hater (BTW: He has "never used" Java so he probably thinks he is the best person to critique it.)
  Well, some of them are probably true, but I would like to say that most of them are not true. I'll explain why.</li>
  </ul>
</blockquote>

<h3>Java is slow</h3>

<p>This can be true sometimes. Java is relatively slow compare to compile-languages like C/C++. You can find a number of statistics about the performance issues of Java.</p>

<h3>Java is dying / dead</h3>

<p>I don't think so. Just try to search on Google. You will be able to smell Java all around the world!</p>

<h3>Java is not free</h3>

<p>Java is free to use. Have ever paid for using Java?</p>

<h3>Java sources are not available / documented</h3>

<p>You can see the source code of fundamental classes of Java such as String, System, or Runtime, and every Java classes, offered by Sun, are well documented.</p>

<h3>J2EE is required for enterprise development</h3>

<p>so what?</p>

<h3>Applets are unusable / slow / dead</h3>

<p>I think applets can be counterproposal for ActiveX technologies on the web. Most Korean banks built up online banking system using ActiveX. I really really hate it. I hope that they use applets instead of ActiveX controls on web pages.</p>

<h3>To learn Java learn Ruby / C</h3>

<p>That's such a bullshit.
I learned Java without Ruby experiences. Well, I could learn Java easily due to C experiences. Having C experiences may help you to learn Java, because many basic statements of Java like 'if', 'for', 'while' are from C. Then, let's think reversely. If you have Java experiences, you will be able to learn easily grammar of C. In conclusion, you don't need to study Ruby or C to learn Java. It's not essential.</p>

<h3>Java is hard to learn</h3>

<p>It all depends on your enthusiasm and inteligent quaility :-)
What is difficult is not Java. It's software development. Do not make a wrong guess.</p>

<p>I always welcome your feedback ;-)</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sumin.us/archives/247/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Object Serialization</title>
		<link>http://blog.sumin.us/archives/136</link>
		<comments>http://blog.sumin.us/archives/136#comments</comments>
		<pubDate>Mon, 13 Mar 2006 17:30:48 +0000</pubDate>
		<dc:creator>Sumin</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.superwtk.com/archives/136</guid>
		<description><![CDATA[Source Code import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.ObjectInput; import java.io.ObjectInputStream; import java.io.ObjectOutput; import java.io.ObjectOutputStream; import java.util.Date; public class Test { public static void main(String[] args) { try { FileOutputStream fos = new FileOutputStream("object"); ObjectOutput oo = new ObjectOutputStream(fos); oo.writeDouble(12.128); oo.writeObject("Today"); oo.writeObject(new Date()); oo.flush(); oo.close(); fos.flush(); fos.close(); FileInputStream fis = new FileInputStream("object"); ObjectInput oi = new [...]]]></description>
			<content:encoded><![CDATA[<h1>Source Code</h1>

<pre><code>import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInput;
import java.io.ObjectInputStream;
import java.io.ObjectOutput;
import java.io.ObjectOutputStream;
import java.util.Date;

public class Test
{
    public static void main(String[] args) {

        try {
            FileOutputStream fos = new FileOutputStream("object");
            ObjectOutput oo = new ObjectOutputStream(fos);

            oo.writeDouble(12.128);
            oo.writeObject("Today");
            oo.writeObject(new Date());
            oo.flush();
            oo.close();

            fos.flush();
            fos.close();

            FileInputStream fis = new FileInputStream("object");
            ObjectInput oi = new ObjectInputStream(fis);

            double d = oi.readDouble();
            String str = (String)oi.readObject();
            Date date = (Date)oi.readObject();

            fis.close();
            oi.close();

            System.out.println(d);
            System.out.println(str);
            System.out.println(date.toString());
        }
        catch (Exception e) {
            e.printStackTrace();
        }
    }
}
</code></pre>

<h1>References</h1>

<ul>
<li><a href="http://java.sun.com/j2se/1.3/docs/guide/serialization/spec/serial-arch.doc2.html">http://java.sun.com/j2se/1.3/docs/guide/serialization/spec/serial-arch.doc2.html</a></li>
</ul>

<!-- (keyword:) 객체 직렬화 -->
]]></content:encoded>
			<wfw:commentRss>http://blog.sumin.us/archives/136/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>J2SE 6 Beta 가 나왔습니다!</title>
		<link>http://blog.sumin.us/archives/185</link>
		<comments>http://blog.sumin.us/archives/185#comments</comments>
		<pubDate>Sat, 18 Feb 2006 23:37:33 +0000</pubDate>
		<dc:creator>Sumin</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://blog.superwtk.com/archives/185</guid>
		<description><![CDATA[http://java.sun.com/javase/webnotes/6/index.html http://java.sun.com/javase/6/download.jsp Beta 버전이라 별로 설치해보고 싶은 생각은 안드는데.. 혹시 설치해보신 분 있나요?]]></description>
			<content:encoded><![CDATA[<p><a href="http://java.sun.com/javase/webnotes/6/index.html">http://java.sun.com/javase/webnotes/6/index.html</a><br />
<a href="http://java.sun.com/javase/6/download.jsp">http://java.sun.com/javase/6/download.jsp</a></p>

<p>Beta 버전이라 별로 설치해보고 싶은 생각은 안드는데..
혹시 설치해보신 분 있나요?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.sumin.us/archives/185/feed</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
