<?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>格物致知 &#187; Java</title>
	<atom:link href="http://leeing.org/tag/java/feed/" rel="self" type="application/rss+xml" />
	<link>http://leeing.org</link>
	<description>keep Thinking</description>
	<lastBuildDate>Fri, 04 Nov 2011 16:20:46 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.1.4</generator>
		<item>
		<title>Swing : 将 System.out 重定向到 JTextArea 和 JTextPane (2)</title>
		<link>http://leeing.org/2011/11/05/swing-%e5%b0%86-system-out-%e9%87%8d%e5%ae%9a%e5%90%91%e5%88%b0-jtextarea-%e5%92%8c-jtextpane-%e5%b0%81%e8%a3%85%e7%89%88/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://leeing.org/2011/11/05/swing-%e5%b0%86-system-out-%e9%87%8d%e5%ae%9a%e5%90%91%e5%88%b0-jtextarea-%e5%92%8c-jtextpane-%e5%b0%81%e8%a3%85%e7%89%88/#comments</comments>
		<pubDate>Fri, 04 Nov 2011 16:19:28 +0000</pubDate>
		<dc:creator>leeing</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[多线程]]></category>
		<category><![CDATA[Swing]]></category>

		<guid isPermaLink="false">http://leeing.org/2011/11/05/swing-%e5%b0%86-system-out-%e9%87%8d%e5%ae%9a%e5%90%91%e5%88%b0-jtextarea-%e5%92%8c-jtextpane-%e5%b0%81%e8%a3%85%e7%89%88/</guid>
		<description><![CDATA[以前写过一篇文章，《Swing : 将 System.out 重定向到 JTextArea 和 JTextPane》，只提及了如何通过重写来进行流的重定向，没有提供一个良好的接口来直接使用，今天看到： 所以利用睡前的一点时间，重新封装了一下之前的代码，原理不变，代码如下： package org.leeing.swing.util; import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; import javax.swing.JTextArea; import javax.swing.SwingUtilities; /** * 工具类，将 stdout 及 stderr 重定向到 JTextArea * @author leeing */ public class PrintUtil { private static void updateTextArea(final JTextArea textArea,final String text) { SwingUtilities.invokeLater(new Runnable() { public void run() { textArea.append(text); } [...]


Related posts:<ol><li><a href='http://leeing.org/2010/04/30/swing-redirecting-system-out-and-system-err-to-jtextpane-or-jtextarea/' rel='bookmark' title='Permanent Link: Swing : 将 System.out 重定向到 JTextArea 和 JTextPane'>Swing : 将 System.out 重定向到 JTextArea 和 JTextPane</a></li>
<li><a href='http://leeing.org/2011/01/18/java-io-%e7%ae%80%e4%bb%8b/' rel='bookmark' title='Permanent Link: Java IO 简介'>Java IO 简介</a></li>
<li><a href='http://leeing.org/2011/02/24/java-%e5%a4%9a%e7%ba%bf%e7%a8%8b%ef%bc%9a%e6%8d%95%e6%8d%89%e7%ba%bf%e7%a8%8b%e4%b8%ad%e9%80%83%e9%80%b8%e7%9a%84%e5%bc%82%e5%b8%b8/' rel='bookmark' title='Permanent Link: Java 多线程：捕捉线程中逃逸的异常'>Java 多线程：捕捉线程中逃逸的异常</a></li>
<li><a href='http://leeing.org/2011/03/17/peersim-%e6%ba%90%e4%bb%a3%e7%a0%81%e5%88%86%e6%9e%90%e4%b9%8b%e4%b8%80%ef%bc%9a%e7%a8%8b%e5%ba%8f%e5%85%a5%e5%8f%a3/' rel='bookmark' title='Permanent Link: PeerSim 源代码分析之一：程序入口'>PeerSim 源代码分析之一：程序入口</a></li>
<li><a href='http://leeing.org/2010/01/17/java-constructor/' rel='bookmark' title='Permanent Link: Java 的构造方法'>Java 的构造方法</a></li>
</ol>]]></description>
		<wfw:commentRss>http://leeing.org/2011/11/05/swing-%e5%b0%86-system-out-%e9%87%8d%e5%ae%9a%e5%90%91%e5%88%b0-jtextarea-%e5%92%8c-jtextpane-%e5%b0%81%e8%a3%85%e7%89%88/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>内螺旋矩阵</title>
		<link>http://leeing.org/2011/10/31/%e5%86%85%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://leeing.org/2011/10/31/%e5%86%85%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/#comments</comments>
		<pubDate>Mon, 31 Oct 2011 13:00:11 +0000</pubDate>
		<dc:creator>leeing</dc:creator>
				<category><![CDATA[面试]]></category>
		<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://leeing.org/2011/10/31/%e5%86%85%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/</guid>
		<description><![CDATA[暂且就叫内螺旋矩阵吧。 int i=5; 1 2 3 4 5 16 17 18 19 6 15 24 25 20 7 14 23 22 21 8 13 12 11 10 9 int i=6 1 2 3 4 5 6 20 21 22 23 24 7 19 32 33 34 25 8 18 31 36 35 26 9 17 [...]


Related posts:<ol><li><a href='http://leeing.org/2011/10/18/%e4%b8%89%e8%a7%92%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/' rel='bookmark' title='Permanent Link: 三角螺旋矩阵'>三角螺旋矩阵</a></li>
<li><a href='http://leeing.org/2011/10/17/%e5%af%b9%e7%a7%b0%e7%9f%a9%e9%98%b5/' rel='bookmark' title='Permanent Link: 对称矩阵'>对称矩阵</a></li>
<li><a href='http://leeing.org/2011/10/17/%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/' rel='bookmark' title='Permanent Link: 蛇形矩阵'>蛇形矩阵</a></li>
<li><a href='http://leeing.org/2011/03/17/peersim-%e6%ba%90%e4%bb%a3%e7%a0%81%e5%88%86%e6%9e%90%e4%b9%8b%e4%b8%80%ef%bc%9a%e7%a8%8b%e5%ba%8f%e5%85%a5%e5%8f%a3/' rel='bookmark' title='Permanent Link: PeerSim 源代码分析之一：程序入口'>PeerSim 源代码分析之一：程序入口</a></li>
<li><a href='http://leeing.org/2010/01/17/java-%e7%9a%84%e5%bc%95%e7%94%a8%e4%bc%a0%e9%80%92/' rel='bookmark' title='Permanent Link: Java 的引用传递'>Java 的引用传递</a></li>
</ol>]]></description>
		<wfw:commentRss>http://leeing.org/2011/10/31/%e5%86%85%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>三角螺旋矩阵</title>
		<link>http://leeing.org/2011/10/18/%e4%b8%89%e8%a7%92%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://leeing.org/2011/10/18/%e4%b8%89%e8%a7%92%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/#comments</comments>
		<pubDate>Tue, 18 Oct 2011 02:56:03 +0000</pubDate>
		<dc:creator>leeing</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[面试]]></category>

		<guid isPermaLink="false">http://leeing.org/2011/10/18/%e4%b8%89%e8%a7%92%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/</guid>
		<description><![CDATA[据说是Yahoo的一道题，题目如下： 打印如下矩阵，如果 n=7 则输出： 1 2 18 3 19 17 4 20 27 16 5 21 28 26 15 6 22 23 24 25 14 7 8 9 10 11 12 13 　 注意观察可知，数字增加的方向及走过的步数是有规律的： &#160; 向下 7 步 向右 6 步 斜上 5 步 向下 4 步 向右 3 步 斜上 2 步 向下 1 [...]


Related posts:<ol><li><a href='http://leeing.org/2011/10/31/%e5%86%85%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/' rel='bookmark' title='Permanent Link: 内螺旋矩阵'>内螺旋矩阵</a></li>
<li><a href='http://leeing.org/2011/10/17/%e5%af%b9%e7%a7%b0%e7%9f%a9%e9%98%b5/' rel='bookmark' title='Permanent Link: 对称矩阵'>对称矩阵</a></li>
<li><a href='http://leeing.org/2011/10/17/%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/' rel='bookmark' title='Permanent Link: 蛇形矩阵'>蛇形矩阵</a></li>
<li><a href='http://leeing.org/2010/01/17/java-%e7%9a%84%e5%bc%95%e7%94%a8%e4%bc%a0%e9%80%92/' rel='bookmark' title='Permanent Link: Java 的引用传递'>Java 的引用传递</a></li>
<li><a href='http://leeing.org/2010/01/17/java-constructor/' rel='bookmark' title='Permanent Link: Java 的构造方法'>Java 的构造方法</a></li>
</ol>]]></description>
		<wfw:commentRss>http://leeing.org/2011/10/18/%e4%b8%89%e8%a7%92%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>对称矩阵</title>
		<link>http://leeing.org/2011/10/17/%e5%af%b9%e7%a7%b0%e7%9f%a9%e9%98%b5/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://leeing.org/2011/10/17/%e5%af%b9%e7%a7%b0%e7%9f%a9%e9%98%b5/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 09:33:21 +0000</pubDate>
		<dc:creator>leeing</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[面试]]></category>

		<guid isPermaLink="false">http://leeing.org/2011/10/17/%e5%af%b9%e7%a7%b0%e7%9f%a9%e9%98%b5/</guid>
		<description><![CDATA[有道的面试题。 写一个函数，打印一个如下的 n x n 的矩阵： &#160; n = 5 1 1 1 1 1 1 2 3 2 1 1 3 6 3 1 1 2 3 2 1 1 1 1 1 1 n = 6 1 1 1 1 1 1 1 2 3 3 2 1 1 3 6 6 3 [...]


Related posts:<ol><li><a href='http://leeing.org/2011/10/18/%e4%b8%89%e8%a7%92%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/' rel='bookmark' title='Permanent Link: 三角螺旋矩阵'>三角螺旋矩阵</a></li>
<li><a href='http://leeing.org/2011/10/31/%e5%86%85%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/' rel='bookmark' title='Permanent Link: 内螺旋矩阵'>内螺旋矩阵</a></li>
<li><a href='http://leeing.org/2011/10/17/%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/' rel='bookmark' title='Permanent Link: 蛇形矩阵'>蛇形矩阵</a></li>
<li><a href='http://leeing.org/2010/01/17/java-constructor/' rel='bookmark' title='Permanent Link: Java 的构造方法'>Java 的构造方法</a></li>
<li><a href='http://leeing.org/2010/01/17/java-%e7%9a%84%e5%bc%95%e7%94%a8%e4%bc%a0%e9%80%92/' rel='bookmark' title='Permanent Link: Java 的引用传递'>Java 的引用传递</a></li>
</ol>]]></description>
		<wfw:commentRss>http://leeing.org/2011/10/17/%e5%af%b9%e7%a7%b0%e7%9f%a9%e9%98%b5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>蛇形矩阵</title>
		<link>http://leeing.org/2011/10/17/%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://leeing.org/2011/10/17/%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/#comments</comments>
		<pubDate>Mon, 17 Oct 2011 06:43:54 +0000</pubDate>
		<dc:creator>leeing</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[算法]]></category>

		<guid isPermaLink="false">http://leeing.org/2011/10/17/%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/</guid>
		<description><![CDATA[经常看到一道笔试题，是关于打印矩阵的，今天抽空写了一个实现。题目如下： 打印如下形式的矩阵： 当 n=5 时： 1 2 9 10 25 4 3 8 11 24 5 6 7 12 23 16 15 14 13 22 17 18 19 20 21 当 n=6 时: 1 2 9 10 25 26 4 3 8 11 24 27 5 6 7 12 23 28 16 15 14 13 [...]


Related posts:<ol><li><a href='http://leeing.org/2010/01/17/java-%e7%9a%84%e5%bc%95%e7%94%a8%e4%bc%a0%e9%80%92/' rel='bookmark' title='Permanent Link: Java 的引用传递'>Java 的引用传递</a></li>
<li><a href='http://leeing.org/2010/01/17/java-constructor/' rel='bookmark' title='Permanent Link: Java 的构造方法'>Java 的构造方法</a></li>
<li><a href='http://leeing.org/2011/10/17/%e5%af%b9%e7%a7%b0%e7%9f%a9%e9%98%b5/' rel='bookmark' title='Permanent Link: 对称矩阵'>对称矩阵</a></li>
<li><a href='http://leeing.org/2011/02/24/java-%e5%a4%9a%e7%ba%bf%e7%a8%8b%ef%bc%9a%e6%8d%95%e6%8d%89%e7%ba%bf%e7%a8%8b%e4%b8%ad%e9%80%83%e9%80%b8%e7%9a%84%e5%bc%82%e5%b8%b8/' rel='bookmark' title='Permanent Link: Java 多线程：捕捉线程中逃逸的异常'>Java 多线程：捕捉线程中逃逸的异常</a></li>
<li><a href='http://leeing.org/2011/10/18/%e4%b8%89%e8%a7%92%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/' rel='bookmark' title='Permanent Link: 三角螺旋矩阵'>三角螺旋矩阵</a></li>
</ol>]]></description>
		<wfw:commentRss>http://leeing.org/2011/10/17/%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>一道面试题：List 中的 Remove 方法</title>
		<link>http://leeing.org/2011/06/16/adobe-%e7%9a%84%e4%b8%80%e9%81%93%e9%9d%a2%e8%af%95%e9%a2%98/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://leeing.org/2011/06/16/adobe-%e7%9a%84%e4%b8%80%e9%81%93%e9%9d%a2%e8%af%95%e9%a2%98/#comments</comments>
		<pubDate>Thu, 16 Jun 2011 12:07:36 +0000</pubDate>
		<dc:creator>leeing</dc:creator>
				<category><![CDATA[Java]]></category>

		<guid isPermaLink="false">http://leeing.org/2011/06/16/adobe-%e7%9a%84%e4%b8%80%e9%81%93%e9%9d%a2%e8%af%95%e9%a2%98/</guid>
		<description><![CDATA[有一道题，是关于 List.remove( int ) 和 List.remove (Object ) 两个方法的，在 List 的元素类型为 Integer 的时候，究竟调用的哪个 API，即：删除对应的整数，或者是删除对应下标的元素 ? 下边来看 List 接口出现的 API: remove E remove(int index) 移除列表中指定位置的元素（可选操作）。将所有的后续元素向左移动（将其索引减 1）。返回从列表中移除的元素。 参数： index &#8211; 要移除的元素的索引 返回： 以前在指定位置的元素 抛出： UnsupportedOperationException &#8211; 如果列表不支持 remove 操作 IndexOutOfBoundsException &#8211; 如果索引超出范围 (index &#60; 0 &#124;&#124; index &#62;= size()) &#160; remove boolean remove(Object o) 从此列表中移除第一次出现的指定元素（如果存在）（可选操作）。如果列表不包含元素，则不更改列表。更确切地讲，移除满足 (o==null ? [...]


Related posts:<ol><li><a href='http://leeing.org/2010/04/19/scala-collection-list/' rel='bookmark' title='Permanent Link: Scala 集合框架：List'>Scala 集合框架：List</a></li>
</ol>]]></description>
		<wfw:commentRss>http://leeing.org/2011/06/16/adobe-%e7%9a%84%e4%b8%80%e9%81%93%e9%9d%a2%e8%af%95%e9%a2%98/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Java 多线程：捕捉线程中逃逸的异常</title>
		<link>http://leeing.org/2011/02/24/java-%e5%a4%9a%e7%ba%bf%e7%a8%8b%ef%bc%9a%e6%8d%95%e6%8d%89%e7%ba%bf%e7%a8%8b%e4%b8%ad%e9%80%83%e9%80%b8%e7%9a%84%e5%bc%82%e5%b8%b8/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://leeing.org/2011/02/24/java-%e5%a4%9a%e7%ba%bf%e7%a8%8b%ef%bc%9a%e6%8d%95%e6%8d%89%e7%ba%bf%e7%a8%8b%e4%b8%ad%e9%80%83%e9%80%b8%e7%9a%84%e5%bc%82%e5%b8%b8/#comments</comments>
		<pubDate>Thu, 24 Feb 2011 07:22:17 +0000</pubDate>
		<dc:creator>leeing</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[多线程]]></category>

		<guid isPermaLink="false">http://leeing.org/2011/02/24/java-%e5%a4%9a%e7%ba%bf%e7%a8%8b%ef%bc%9a%e6%8d%95%e6%8d%89%e7%ba%bf%e7%a8%8b%e4%b8%ad%e9%80%83%e9%80%b8%e7%9a%84%e5%bc%82%e5%b8%b8/</guid>
		<description><![CDATA[由于线程的本质特性，不能捕获从线程中抛出的异常，一但异常跳出run方法，就会直接输出到控制台。在Java5中，可以用Executor来解决这个问题。 Thread.UncaughtExceptionHandler接口允许在每个Thread对象上附着一个异常处理器，它的uncaughtException方法会在线程因未捕获的异常而临近死亡时被调用。我们可以创建一个ThreadFactory，它将在每个新创建的Thread对象上附着Thread.UncaughtExceptionHanlder。 import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; import java.util.concurrent.ThreadFactory; class ExceptionThread2 implements Runnable{ public void run() { Thread t = Thread.currentThread(); System.out.println(&#34;run() by &#34;+t); System.out.println(&#34;eh = &#34;+t.getUncaughtExceptionHandler()); throw new RuntimeException(); } } class MyUncaughtExceptionHandler implements Thread.UncaughtExceptionHandler{ public void uncaughtException(Thread t, Throwable e) { System.out.println(&#34;caught &#34;+e); } } class HandlerThreadFactory implements ThreadFactory{ public Thread newThread(Runnable r) { [...]


Related posts:<ol><li><a href='http://leeing.org/2010/01/17/java-constructor/' rel='bookmark' title='Permanent Link: Java 的构造方法'>Java 的构造方法</a></li>
<li><a href='http://leeing.org/2010/01/17/java-%e7%9a%84%e5%bc%95%e7%94%a8%e4%bc%a0%e9%80%92/' rel='bookmark' title='Permanent Link: Java 的引用传递'>Java 的引用传递</a></li>
<li><a href='http://leeing.org/2011/11/05/swing-%e5%b0%86-system-out-%e9%87%8d%e5%ae%9a%e5%90%91%e5%88%b0-jtextarea-%e5%92%8c-jtextpane-%e5%b0%81%e8%a3%85%e7%89%88/' rel='bookmark' title='Permanent Link: Swing : 将 System.out 重定向到 JTextArea 和 JTextPane (2)'>Swing : 将 System.out 重定向到 JTextArea 和 JTextPane (2)</a></li>
<li><a href='http://leeing.org/2011/10/17/%e5%af%b9%e7%a7%b0%e7%9f%a9%e9%98%b5/' rel='bookmark' title='Permanent Link: 对称矩阵'>对称矩阵</a></li>
<li><a href='http://leeing.org/2011/10/17/%e8%9e%ba%e6%97%8b%e7%9f%a9%e9%98%b5/' rel='bookmark' title='Permanent Link: 蛇形矩阵'>蛇形矩阵</a></li>
</ol>]]></description>
		<wfw:commentRss>http://leeing.org/2011/02/24/java-%e5%a4%9a%e7%ba%bf%e7%a8%8b%ef%bc%9a%e6%8d%95%e6%8d%89%e7%ba%bf%e7%a8%8b%e4%b8%ad%e9%80%83%e9%80%b8%e7%9a%84%e5%bc%82%e5%b8%b8/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java IO 简介</title>
		<link>http://leeing.org/2011/01/18/java-io-%e7%ae%80%e4%bb%8b/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://leeing.org/2011/01/18/java-io-%e7%ae%80%e4%bb%8b/#comments</comments>
		<pubDate>Tue, 18 Jan 2011 02:01:48 +0000</pubDate>
		<dc:creator>leeing</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[IO]]></category>

		<guid isPermaLink="false">http://leeing.org/2011/01/18/java-io-%e7%ae%80%e4%bb%8b/</guid>
		<description><![CDATA[Java.io包是用术语流(stream)来定义的，流是有序的数据序列，它有一个源(输入流)或一个目的地(输出流) ,它代表任何有能力产生数据的数据源对象或者有能力接收数据的接收端对象，它屏蔽了实际I/O设备中处理数据的细节。 Java.nio包是用术语Channel 和buffer来定义I/O的。缓冲区是可以从中读取或写入的数据存储（类似于数组），通道表示的是能够执行I/O操作的实体的连接，这些实体包括缓冲区，文件和套接字。NIO和OIO的区别主要在于Channel允许不阻塞的I/O操作和可中断的阻塞操作，这对于高吞吐量的服务器应用是至关重要的。 Java.net包是基于对套接字的使用，用一种基于流，或者基于通道的模型提供了对网络I/O的特殊支持。 Java.io中的字符流，字符是指16位的UTF-16字符。 关闭流可以释放该流可能使用过的资源（如文件描述符），这些资源在不再使用时尽快回收;而如果某个流未被显式地关闭，则继续持有这些资源。流类可以定义finalize方法，但是通常在完成流的操作以后，就应该将其关闭。如果流已经被关闭，之后在其上操作会触发IOException，而关闭一个已经被关闭了的流则不会有任何的影响。（即流可以重复关闭，但不能在关闭之后继续使用） 所有的字节流都具有相同的同步策略和并发行为。 下面主要说明一些特别要注意的方法： InputStream public abstract int read() throws IOException 这个是唯一需要重写的方法，用以读取数据的一个单个字节，并返回0~255之间的整数，如果已经达到流的末尾，则将返回-1。注意，这个方法将发生阻塞直到可获取输入，到达流的末尾，或者抛出异常。这个方法返回的是一个int而不是byte值，因为它需要返回所的有效的字节值加上一个表示末尾的标志值，这就要求标志值要超出byte的范围，所以就采用了更大的int。注意 System.in就是InputStream类型的。 OutputStream public abstract void write(int b) throws IOException 将b作为一个字节写入，由于是int类型，只有此整数的最低8位会被写入，此方法将阻塞直至字节写入完成。 InputStream和OuputStream分别只要求子类实现其read和write方法，因为其它read,write方法都是在此基础上定义的，大多数流都可以通过覆盖read或write方法来提高性能，而OutputStream中的flush和close方法的默认实现通常都需要在特定的流中进行恰当的覆盖，尤其是被缓冲的流，可能需要在关闭的时候进行刷新。 设计Reader和Writer类继承层次主要是为了国际化，因为16位的Unicode用于字符国际化，所以添加这两个类层次就是为了在所有的I/O操作中支持Unicode，此外，新类库的设计使得它的操作比旧类库要快。在应用中，最明智的做法应该是：尽量尝试使用Reader和Writer，一旦程序代码无法成功编译，才使用面向字节的类库。例如，java.util.zip就是只面向字节的。 对于Reader和Writer类，字节byte要换成字符char，read的返回值在0~65535之间，write写入的是char（int 类型的低16位）。 Reader与InputStream有很多不同，首先，Reader要求必须实现的两个方法是： public abstract int read(char[] buf, int offset, int count) public abstract void close() throws IOException 同时，InputStream提供了一个available方法用以返回此输入流下一个方法调用可以不受阻塞地从此输入流读取（或跳过）的估计字节数。而Reader只有一个ready方法来让我们了解是否有数据可以读取。 而类似地，Writer要求子类必须实现以下3个方法： public abstract void write(char[] buf, int [...]


Related posts:<ol><li><a href='http://leeing.org/2010/04/30/swing-redirecting-system-out-and-system-err-to-jtextpane-or-jtextarea/' rel='bookmark' title='Permanent Link: Swing : 将 System.out 重定向到 JTextArea 和 JTextPane'>Swing : 将 System.out 重定向到 JTextArea 和 JTextPane</a></li>
<li><a href='http://leeing.org/2011/11/05/swing-%e5%b0%86-system-out-%e9%87%8d%e5%ae%9a%e5%90%91%e5%88%b0-jtextarea-%e5%92%8c-jtextpane-%e5%b0%81%e8%a3%85%e7%89%88/' rel='bookmark' title='Permanent Link: Swing : 将 System.out 重定向到 JTextArea 和 JTextPane (2)'>Swing : 将 System.out 重定向到 JTextArea 和 JTextPane (2)</a></li>
<li><a href='http://leeing.org/2010/01/17/java-constructor/' rel='bookmark' title='Permanent Link: Java 的构造方法'>Java 的构造方法</a></li>
<li><a href='http://leeing.org/2011/02/24/java-%e5%a4%9a%e7%ba%bf%e7%a8%8b%ef%bc%9a%e6%8d%95%e6%8d%89%e7%ba%bf%e7%a8%8b%e4%b8%ad%e9%80%83%e9%80%b8%e7%9a%84%e5%bc%82%e5%b8%b8/' rel='bookmark' title='Permanent Link: Java 多线程：捕捉线程中逃逸的异常'>Java 多线程：捕捉线程中逃逸的异常</a></li>
<li><a href='http://leeing.org/2010/01/17/java-%e7%9a%84%e5%bc%95%e7%94%a8%e4%bc%a0%e9%80%92/' rel='bookmark' title='Permanent Link: Java 的引用传递'>Java 的引用传递</a></li>
</ol>]]></description>
		<wfw:commentRss>http://leeing.org/2011/01/18/java-io-%e7%ae%80%e4%bb%8b/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>用户访问行为，齐普夫分布及其 Java 实现</title>
		<link>http://leeing.org/2010/05/18/user-behavior-zipf-distribution-and-java-implementation/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://leeing.org/2010/05/18/user-behavior-zipf-distribution-and-java-implementation/#comments</comments>
		<pubDate>Tue, 18 May 2010 08:47:02 +0000</pubDate>
		<dc:creator>leeing</dc:creator>
				<category><![CDATA[CDN]]></category>
		<category><![CDATA[Java]]></category>
		<category><![CDATA[R]]></category>
		<category><![CDATA[Zipf distribution]]></category>

		<guid isPermaLink="false">http://leeing.org/?p=541</guid>
		<description><![CDATA[Zipf定律是文献计量学的重要定律之一，它和罗特卡定律、布拉德福定律一起被并称为文献计量学的三大定律。 对于CDN的内容管理，也近似符合Zipf 定律，就是大家常说对于内容的访问遵循80/20原则，也就是20%的内容，会占有80%的访问量。 这里 r 表示一个单词的出现频率的排名，P(r)表示排名为r的单词的出现频率. (单词频率分布中 C约等于0.1, a约等于1) 后人将这个分布称为zipf distribution，中文名称为齐普夫分布或Zeta 分布。这是一个离散事件分布，广泛应用于语言学，保险学，网络模拟，以及对稀疏事件的建模中。 它表明在英语单词中,只有极少数的词被经常使用,而绝大多数词很少被使用。实际上,包括汉语在内的许多国家的语言都有这种特点。这个定律后来在很多领域得到了同样的验证，包括网站的访问者数量、城镇的大小和每个国家公司的数量。。这个定理也在很多分布里面得到了验证，比如人们的收入，互联网的网站数量和访问比例，互联网内容和访问比例(其他分布两个常数有所不同,a越大，分布越密集,对于VOD来说某些时候符合双zipf分布)。 比起枯燥的公式，图表更具有说服力，下面是用三百个严格符合zipf 分布的数据点描绘成的图，其中横轴表示排名，纵轴表示访问的频率，分别使用线性坐标和对数坐标表示： 可以看到对数坐标下是一条完美的直线。 在很多网页的用户访问行为中，都是近似于zipf 分布的，例如下表是www.sun.com 在1996 年7月的页面访问情况： zipf 定律也可以用于其它领域，例如下面的表格的横轴表示城市的人口排名的对数值，而纵轴则是人口数量的对数值。 编程实现：Mathematica，R，还有Java都有相应的API，在这里，主要讨论Java。 在模拟用户的访问请求时，可以近似地使用zipf 定律， Apache Foundation 的commons-math 项目提供了一个Java实现： 在org.apache.commons.math.distribution 包中的类： ZipfDistributionImpl(int numberOfElements, double exponent) Create a new Zipf distribution with the given number of elements and exponent. 它提供的方法主要有： double cumulativeProbability(int x) 概率密度函数：P(X &#60;= x) 的值。 [...]


Related posts:<ol><li><a href='http://leeing.org/2010/01/17/java-%e7%9a%84%e5%bc%95%e7%94%a8%e4%bc%a0%e9%80%92/' rel='bookmark' title='Permanent Link: Java 的引用传递'>Java 的引用传递</a></li>
<li><a href='http://leeing.org/2010/01/17/java-constructor/' rel='bookmark' title='Permanent Link: Java 的构造方法'>Java 的构造方法</a></li>
<li><a href='http://leeing.org/2011/01/18/java-io-%e7%ae%80%e4%bb%8b/' rel='bookmark' title='Permanent Link: Java IO 简介'>Java IO 简介</a></li>
<li><a href='http://leeing.org/2011/02/24/java-%e5%a4%9a%e7%ba%bf%e7%a8%8b%ef%bc%9a%e6%8d%95%e6%8d%89%e7%ba%bf%e7%a8%8b%e4%b8%ad%e9%80%83%e9%80%b8%e7%9a%84%e5%bc%82%e5%b8%b8/' rel='bookmark' title='Permanent Link: Java 多线程：捕捉线程中逃逸的异常'>Java 多线程：捕捉线程中逃逸的异常</a></li>
</ol>]]></description>
		<wfw:commentRss>http://leeing.org/2010/05/18/user-behavior-zipf-distribution-and-java-implementation/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Netbeans 性能调优及加速</title>
		<link>http://leeing.org/2010/05/05/improve-the-performance-of-netbeans/#utm_source=feed&#038;utm_medium=feed&#038;utm_campaign=feed</link>
		<comments>http://leeing.org/2010/05/05/improve-the-performance-of-netbeans/#comments</comments>
		<pubDate>Wed, 05 May 2010 13:31:45 +0000</pubDate>
		<dc:creator>leeing</dc:creator>
				<category><![CDATA[Java]]></category>
		<category><![CDATA[NetBeans]]></category>

		<guid isPermaLink="false">http://leeing.org/?p=536</guid>
		<description><![CDATA[NetBeans  安装目录下的 netbeans.conf  文件中的 netbeans_default_options  能够对 NetBeans 的启动，运行以及编译的速度产生很大的影响，恰当地设值可以让 NetBeans 的性能有大幅提升，当然如果设置的值过高也能导致 NetBeans 无法启动。 我的内存是 2GB 的，netbeans_default-options 设置为以下的参数，运行速度很快，在这里做个备份供以后参考。 netbeans_default_options="-J-Dfile.encoding=UTF-8 -J-XX:PermSize=128m -J-XX:MaxPermSize=256m -J-Xmx1024m -J-Duser.language=en -J-client -J-Xverify:none -J-Xss2m -J-Xms512m -J-Dapple.laf.useScreenMenuBar=true -J-Dsun.java2d.noddraw=true -J-XX:+UseConcMarkSweepGC -J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled" Related posts:Netbeans 6.8 字体设置


Related posts:<ol><li><a href='http://leeing.org/2010/03/24/netbeans-6-8-font-configuration/' rel='bookmark' title='Permanent Link: Netbeans 6.8 字体设置'>Netbeans 6.8 字体设置</a></li>
</ol>]]></description>
		<wfw:commentRss>http://leeing.org/2010/05/05/improve-the-performance-of-netbeans/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

