<?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>HITANGJUN BLOG &#187; IT技术</title>
	<atom:link href="http://blog.hitangjun.com/category/ittechnology/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.hitangjun.com</link>
	<description>专注于 JAVA  WEB开发</description>
	<lastBuildDate>Fri, 16 Dec 2011 03:05:33 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3</generator>
		<item>
		<title>java如何正确处理断点续传</title>
		<link>http://blog.hitangjun.com/2011/12/16/how-does-java-process-interruption-resuming/</link>
		<comments>http://blog.hitangjun.com/2011/12/16/how-does-java-process-interruption-resuming/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 02:40:43 +0000</pubDate>
		<dc:creator>tj4c</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[java]]></category>

		<guid isPermaLink="false">http://blog.hitangjun.com/?p=2121</guid>
		<description><![CDATA[关于JAVA如何正确的处理静态文件，数据流的断点续传，查阅许多资料后，还是在tomcat中找到了灵感，具体请参考org.apache.catalina.servlets.DefaultServlet 简单说明下，关于tomcat处理资源请求的主要包括： 1 处理流程在 protected void serveResource(HttpServletRequest request,HttpServletResponse response,boolean content) 中 2 使用缓存进行处理 CacheEntry cacheEntry = resources.lookupCache(path); 3 解析Range的正确方式请参考 // Parse range specifier 765 ranges = parseRange(request, response, cacheEntry.attributes); 766 767 // ETag header 768 response.setHeader("ETag", cacheEntry.attributes.getETag()); 769 770 // Last-Modified header 771 response.setHeader("Last-Modified", 772 cacheEntry.attributes.getLastModifiedHttp()); 773 774 // Get content length 775 contentLength = [...]]]></description>
			<content:encoded><![CDATA[<p>关于JAVA如何正确的处理静态文件，数据流的断点续传，查阅许多资料后，还是在tomcat中找到了灵感，具体请参考<a href="http://www.docjar.com/html/api/org/apache/catalina/servlets/DefaultServlet.java.html" title="查看源码" target="_blank">org.apache.catalina.servlets.DefaultServlet </a></p>
<p>简单说明下，关于tomcat处理资源请求的主要包括：<br />
1 处理流程在 protected void serveResource(HttpServletRequest request,HttpServletResponse response,boolean content) 中<br />
2 使用缓存进行处理 CacheEntry cacheEntry = resources.lookupCache(path);<br />
3 解析Range的正确方式请参考 <code>// Parse range specifier<br />
  765               ranges = parseRange(request, response, cacheEntry.attributes);<br />
  766<br />
  767               // ETag header<br />
  768               response.setHeader("ETag", cacheEntry.attributes.getETag());<br />
  769<br />
  770               // Last-Modified header<br />
  771               response.setHeader("Last-Modified",<br />
  772                       cacheEntry.attributes.getLastModifiedHttp());<br />
  773<br />
  774               // Get content length<br />
  775               contentLength = cacheEntry.attributes.getContentLength();<br />
  776               // Special case for zero length files, which would cause a<br />
  777               // (silent) ISE when setting the output buffer size<br />
  778               if (contentLength == 0L) {<br />
  779                   content = false;<br />
  780               }</code></p>
<p>这个方法才是重点 protected Range parseContentRange(HttpServletRequest request,HttpServletResponse response)</p>
<p>经测试，完美支持CHROME,IE,FF,ANDROID,IPAD,IPHONE,SAFARI。<br />
大家可以参考来处理静态资源或是数据流<br />
下面的是整合后的代码，有删改</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2121code2'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p21212"><td class="code" id="p2121code2"><pre class="java" style="font-family:monospace;"> <span style="color: #000000; font-weight: bold;">public</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> readFile<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
	   <span style="color: #000066; font-weight: bold;">long</span> start <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	   <span style="color: #666666; font-style: italic;">//open virtual dir file in cloud </span>
	   mongodbfile cloudStore <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> mongodbfile<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	   <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Abufferedoutputstream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">BufferedOutputStream</span></a> bos <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
	   <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> fileId <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;&quot;</span><span style="color: #339933;">;</span>
	   getResponse<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">reset</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	   getResponse<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">resetBuffer</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> bufferSize <span style="color: #339933;">=</span> <span style="color: #cc66cc;">1024</span><span style="color: #339933;">;</span>
	   getResponse<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setBufferSize</span><span style="color: #009900;">&#40;</span>bufferSize<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	   <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
		 getResponse<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;image/&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #666666; font-style: italic;">//请相应修改</span>
		 getResponse<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Accept-Ranges&quot;</span>, <span style="color: #0000ff;">&quot;bytes&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		   log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;readCloudStoreFile fileId = {}&quot;</span>,fileId<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		   <span style="color: #000066; font-weight: bold;">int</span> readResult <span style="color: #339933;">=</span> cloudStore.<span style="color: #006633;">ReadBegin</span><span style="color: #009900;">&#40;</span>fileId<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>readResult <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span><span style="color: #666666; font-style: italic;">//文件读取成功</span>
			   <span style="color: #000066; font-weight: bold;">long</span> contentLength <span style="color: #339933;">=</span> cloudStore.<span style="color: #006633;">GetFileLength</span><span style="color: #009900;">&#40;</span>fileId<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                           <span style="color: #666666; font-style: italic;">//模拟Etag的信息</span>
			   getResponse<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Etag&quot;</span>, <span style="color: #0000ff;">&quot;W/<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>contentLength<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;-1316052976000<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			   getResponse<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Last-Modified&quot;</span>, <span style="color: #0000ff;">&quot;Thu, 15 Sep 2011 02:16:16 GMT&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			   <span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span><span style="color: #009900;">&#93;</span> buffer <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <span style="color: #000066; font-weight: bold;">byte</span><span style="color: #009900;">&#91;</span>bufferSize<span style="color: #009900;">&#93;</span><span style="color: #339933;">;</span>
			   bos <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Abufferedoutputstream+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">BufferedOutputStream</span></a><span style="color: #009900;">&#40;</span>getResponse<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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: #000066; font-weight: bold;">long</span> pos <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>			   
			   <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aarraylist+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">ArrayList</span></a> ranges <span style="color: #339933;">=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>			   
			   <span style="color: #000066; font-weight: bold;">long</span> s <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			   <span style="color: #666666; font-style: italic;">// Parse range specifier</span>
                           ranges <span style="color: #339933;">=</span> parseRange<span style="color: #009900;">&#40;</span>request, response, contentLength<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                           <span style="color: #000066; font-weight: bold;">long</span> requestLength <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>			 
               <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>ranges <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span>ranges.<span style="color: #006633;">isEmpty</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span>
                               <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>request.<span style="color: #006633;">getHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Range&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span>
                       <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span>ranges <span style="color: #339933;">==</span> FULL<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
&nbsp;
            	   <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>contentLength <span style="color: #339933;">&lt;</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainteger+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Integer</span></a>.<span style="color: #006633;">MAX_VALUE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
    				   getResponse<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setContentLength</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span> contentLength<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                   <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                       <span style="color: #666666; font-style: italic;">// Set the content-length as String to be able to use a long</span>
                	   getResponse<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;content-length&quot;</span>, <span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">+</span> contentLength<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                   <span style="color: #009900;">&#125;</span>
            	   requestLength <span style="color: #339933;">=</span> contentLength<span style="color: #339933;">;</span>
               <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
		<span style="color: #666666; font-style: italic;">// 若客户端传来Range，说明之前下载了一部分，设置206状态(SC_PARTIAL_CONTENT)</span>
				   getResponse<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">setStatus</span><span style="color: #009900;">&#40;</span>HttpServletResponse.<span style="color: #006633;">SC_PARTIAL_CONTENT</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
				   log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;=======ranges.size() {}&quot;</span>,ranges.<span style="color: #006633;">size</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;">if</span> <span style="color: #009900;">&#40;</span>ranges.<span style="color: #006633;">size</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</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;
		                Range range <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span>Range<span style="color: #009900;">&#41;</span> ranges.<span style="color: #006633;">get</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		                response.<span style="color: #006633;">addHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Range&quot;</span>, <span style="color: #0000ff;">&quot;bytes &quot;</span>
		                                   <span style="color: #339933;">+</span> range.<span style="color: #006633;">start</span>
		                                   <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;-&quot;</span> <span style="color: #339933;">+</span> range.<span style="color: #006633;">end</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;/&quot;</span>
		                                   <span style="color: #339933;">+</span> range.<span style="color: #006633;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		                log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Range:  {}&quot;</span>,<span style="color: #0000ff;">&quot;bytes &quot;</span>
                                <span style="color: #339933;">+</span> range.<span style="color: #006633;">start</span>
                                <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;-&quot;</span> <span style="color: #339933;">+</span> range.<span style="color: #006633;">end</span> <span style="color: #339933;">+</span> <span style="color: #0000ff;">&quot;/&quot;</span>
                                <span style="color: #339933;">+</span> range.<span style="color: #006633;">length</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
<span style="color: #666666; font-style: italic;">//重点在这里对实时请求的数据长度和数据流剩余长度，和写回Response数据长度的判断</span>
		                <span style="color: #000066; font-weight: bold;">long</span> length <span style="color: #339933;">=</span> range.<span style="color: #006633;">end</span> <span style="color: #339933;">-</span> range.<span style="color: #006633;">start</span> <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
		                <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>length <span style="color: #339933;">&lt;</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Ainteger+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Integer</span></a>.<span style="color: #006633;">MAX_VALUE</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		                    response.<span style="color: #006633;">setContentLength</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span> length<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		                <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
		                    <span style="color: #666666; font-style: italic;">// Set the content-length as String to be able to use a long</span>
		                    response.<span style="color: #006633;">setHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;content-length&quot;</span>, <span style="color: #0000ff;">&quot;&quot;</span> <span style="color: #339933;">+</span> length<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		                <span style="color: #009900;">&#125;</span>
		                log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;request range length = {}&quot;</span>,length<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>    
		                pos <span style="color: #339933;">=</span> range.<span style="color: #006633;">start</span><span style="color: #339933;">;</span>
		                requestLength <span style="color: #339933;">=</span> length<span style="color: #339933;">;</span>
		            <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
                                <span style="color: #666666; font-style: italic;">//这里未处理range数组的情况</span>
		                response.<span style="color: #006633;">setContentType</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;multipart/byteranges; boundary=&quot;</span>
		                                        <span style="color: #339933;">+</span> mimeSeparation<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	                    log.<span style="color: #006633;">warn</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;@@@@@@@@@@@ for multipart transfer todo&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		            <span style="color: #009900;">&#125;</span>   
			   <span style="color: #009900;">&#125;</span>
               log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;###########skip pos = {}&quot;</span>,pos<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>pos <span style="color: #339933;">!=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
				   <span style="color: #666666; font-style: italic;">// 略过已经传输过的字节</span>
				   <span style="color: #000066; font-weight: bold;">long</span> sk <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				   cloudStore.<span style="color: #006633;">Skip</span><span style="color: #009900;">&#40;</span>pos<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>				  
			   <span style="color: #009900;">&#125;</span>
			   <span style="color: #000066; font-weight: bold;">long</span> ws <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			   <span style="color: #000000; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span>requestLength <span style="color: #339933;">&lt;</span> bufferSize<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				   bufferSize <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">int</span><span style="color: #009900;">&#41;</span>requestLength<span style="color: #339933;">;</span>
			   <span style="color: #009900;">&#125;</span>
&nbsp;
			   <span style="color: #000066; font-weight: bold;">int</span> readedLen <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
			   <span style="color: #000000; font-weight: bold;">for</span><span style="color: #009900;">&#40;</span><span style="color: #000066; font-weight: bold;">long</span> len <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>len<span style="color: #339933;">&lt;</span>requestLength<span style="color: #339933;">;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
				   readedLen <span style="color: #339933;">=</span> cloudStore.<span style="color: #006633;">Read</span><span style="color: #009900;">&#40;</span>buffer, bufferSize<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				   bos.<span style="color: #006633;">write</span><span style="color: #009900;">&#40;</span>buffer,<span style="color: #cc66cc;">0</span>,readedLen<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
				   len<span style="color: #339933;">+=</span>readedLen<span style="color: #339933;">;</span>
			   <span style="color: #009900;">&#125;</span>
&nbsp;
			   bos.<span style="color: #006633;">flush</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			   log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;write data spent {}&quot;</span>,<a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Asystem+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">System</span></a>.<span style="color: #006633;">currentTimeMillis</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">-</span>ws<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
		   <span style="color: #009900;">&#125;</span>
&nbsp;
		   log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;write to response file success fileId = {}&quot;</span>,fileId<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	   <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Exception</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
	   <span style="color: #009900;">&#125;</span><span style="color: #000000; font-weight: bold;">finally</span><span style="color: #009900;">&#123;</span>
		   <span style="color: #666666; font-style: italic;">//关闭资源	   </span>
	   <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
        <span style="color: #008000; font-style: italic; font-weight: bold;">/**
	 * MIME multipart separation string
	 */</span>
	<span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">static</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> mimeSeparation <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;CATALINA_MIME_BOUNDARY&quot;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #008000; font-style: italic; font-weight: bold;">/**
    * Full range marker.
    */</span>
   <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">static</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aarraylist+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">ArrayList</span></a> FULL <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aarraylist+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">ArrayList</span></a><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
   <span style="color: #008000; font-style: italic; font-weight: bold;">/**
    * Parse the range header.
    *
    * @param request The servlet request we are processing
    * @param response The servlet response we are creating
    * @return Vector of ranges
    */</span>
   <span style="color: #000000; font-weight: bold;">protected</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aarraylist+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">ArrayList</span></a> parseRange<span style="color: #009900;">&#40;</span>HttpServletRequest request,
                               HttpServletResponse response,<span style="color: #000066; font-weight: bold;">long</span> length<span style="color: #009900;">&#41;</span>
       <span style="color: #000000; font-weight: bold;">throws</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aioexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IOException</span></a> <span style="color: #009900;">&#123;</span>
&nbsp;
       <span style="color: #666666; font-style: italic;">// Checking If-Range</span>
       <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> headerValue <span style="color: #339933;">=</span> request.<span style="color: #006633;">getHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;If-Range&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;headerValue = &quot;</span>,headerValue<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>headerValue <span style="color: #339933;">!=</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
           <span style="color: #000066; font-weight: bold;">long</span> headerValueTime <span style="color: #339933;">=</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>1L<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
           <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
               headerValueTime <span style="color: #339933;">=</span> request.<span style="color: #006633;">getDateHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;If-Range&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
           <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Aillegalargumentexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">IllegalArgumentException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
               <span style="color: #339933;">;</span>
           <span style="color: #009900;">&#125;</span>
&nbsp;
           <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> eTag <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;W/<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">+</span>length<span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;-1316052976000<span style="color: #000099; font-weight: bold;">\&quot;</span>&quot;</span><span style="color: #339933;">;</span>
           <span style="color: #000066; font-weight: bold;">long</span> lastModified <span style="color: #339933;">=</span> 1316052976000L<span style="color: #339933;">;</span>
&nbsp;
           log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;headerValueTime = &quot;</span>,headerValueTime<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>headerValueTime <span style="color: #339933;">==</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">-</span>1L<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
               <span style="color: #666666; font-style: italic;">// If the ETag the client gave does not match the entity</span>
               <span style="color: #666666; font-style: italic;">// etag, then the entire entity is returned.</span>
               <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>eTag.<span style="color: #006633;">equals</span><span style="color: #009900;">&#40;</span>headerValue.<span style="color: #006633;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            	   log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;If the ETag the client gave does not match the entity etag, &quot;</span>
                            <span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;then the entire entity is returned.&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            	   <span style="color: #000000; font-weight: bold;">return</span> FULL<span style="color: #339933;">;</span>
               <span style="color: #009900;">&#125;</span>
           <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
               <span style="color: #666666; font-style: italic;">// If the timestamp of the entity the client got is older than</span>
               <span style="color: #666666; font-style: italic;">// the last modification date of the entity, the entire entity</span>
               <span style="color: #666666; font-style: italic;">// is returned.</span>
               <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>lastModified <span style="color: #339933;">&gt;</span> <span style="color: #009900;">&#40;</span>headerValueTime <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1000</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
            	   log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;If the timestamp of the entity the client got is older &quot;</span>
            <span style="color: #339933;">+</span><span style="color: #0000ff;">&quot;than the last modification date of the entity, the entire entity is returned&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
            	   <span style="color: #000000; font-weight: bold;">return</span> FULL<span style="color: #339933;">;</span>
&nbsp;
               <span style="color: #009900;">&#125;</span>
           <span style="color: #009900;">&#125;</span>
&nbsp;
       <span style="color: #009900;">&#125;</span>
&nbsp;
       <span style="color: #000066; font-weight: bold;">long</span> fileLength <span style="color: #339933;">=</span> length<span style="color: #339933;">;</span>
&nbsp;
       <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>fileLength <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span>
           <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
&nbsp;
       <span style="color: #666666; font-style: italic;">// Retrieving the range header (if any is specified</span>
       <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> rangeHeader <span style="color: #339933;">=</span> request.<span style="color: #006633;">getHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Range&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
       log.<span style="color: #006633;">debug</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;rangeHeader = &quot;</span>,rangeHeader<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>rangeHeader <span style="color: #339933;">==</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
    	   <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span>    
       <span style="color: #666666; font-style: italic;">// bytes is the only range unit supported (and I don't see the point</span>
       <span style="color: #666666; font-style: italic;">// of adding new ones).</span>
       <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>rangeHeader.<span style="color: #006633;">startsWith</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;bytes&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
           response.<span style="color: #006633;">addHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Range&quot;</span>, <span style="color: #0000ff;">&quot;bytes */&quot;</span> <span style="color: #339933;">+</span> fileLength<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
           response.<span style="color: #006633;">sendError</span>
               <span style="color: #009900;">&#40;</span>HttpServletResponse.<span style="color: #006633;">SC_REQUESTED_RANGE_NOT_SATISFIABLE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
           <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span>
&nbsp;
       rangeHeader <span style="color: #339933;">=</span> rangeHeader.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">6</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
       <span style="color: #666666; font-style: italic;">// Vector which will contain all the ranges which are successfully</span>
       <span style="color: #666666; font-style: italic;">// parsed.</span>
       ArrayList<span style="color: #339933;">&lt;</span>range<span style="color: #339933;">&gt;</span> result <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> ArrayList<span style="color: #339933;">&lt;/</span>range<span style="color: #339933;">&gt;&lt;</span>range<span style="color: #339933;">&gt;</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astringtokenizer+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">StringTokenizer</span></a> commaTokenizer <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astringtokenizer+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">StringTokenizer</span></a><span style="color: #009900;">&#40;</span>rangeHeader, <span style="color: #0000ff;">&quot;,&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
       <span style="color: #666666; font-style: italic;">// Parsing the range list</span>
       <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #009900;">&#40;</span>commaTokenizer.<span style="color: #006633;">hasMoreTokens</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>
           <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> rangeDefinition <span style="color: #339933;">=</span> commaTokenizer.<span style="color: #006633;">nextToken</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span>.<span style="color: #006633;">trim</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
&nbsp;
           Range currentRange <span style="color: #339933;">=</span> <span style="color: #000000; font-weight: bold;">new</span> Range<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
           currentRange.<span style="color: #006633;">length</span> <span style="color: #339933;">=</span> fileLength<span style="color: #339933;">;</span>
&nbsp;
           <span style="color: #000066; font-weight: bold;">int</span> dashPos <span style="color: #339933;">=</span> rangeDefinition.<span style="color: #006633;">indexOf</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">'-'</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>dashPos <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>
               response.<span style="color: #006633;">addHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Range&quot;</span>, <span style="color: #0000ff;">&quot;bytes */&quot;</span> <span style="color: #339933;">+</span> fileLength<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
               response.<span style="color: #006633;">sendError</span>
                   <span style="color: #009900;">&#40;</span>HttpServletResponse.<span style="color: #006633;">SC_REQUESTED_RANGE_NOT_SATISFIABLE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
               <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
           <span style="color: #009900;">&#125;</span>
&nbsp;
           <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>dashPos <span style="color: #339933;">==</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
&nbsp;
               <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                   <span style="color: #000066; font-weight: bold;">long</span> offset <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Along+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Long</span></a>.<span style="color: #006633;">parseLong</span><span style="color: #009900;">&#40;</span>rangeDefinition<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                   currentRange.<span style="color: #006633;">start</span> <span style="color: #339933;">=</span> fileLength <span style="color: #339933;">+</span> offset<span style="color: #339933;">;</span>
                   currentRange.<span style="color: #006633;">end</span> <span style="color: #339933;">=</span> fileLength <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
               <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Anumberformatexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">NumberFormatException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                   response.<span style="color: #006633;">addHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Range&quot;</span>,
                                      <span style="color: #0000ff;">&quot;bytes */&quot;</span> <span style="color: #339933;">+</span> fileLength<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                   response.<span style="color: #006633;">sendError</span>
                       <span style="color: #009900;">&#40;</span>HttpServletResponse
                        .<span style="color: #006633;">SC_REQUESTED_RANGE_NOT_SATISFIABLE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                   <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
               <span style="color: #009900;">&#125;</span>
&nbsp;
           <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">else</span> <span style="color: #009900;">&#123;</span>
&nbsp;
               <span style="color: #000000; font-weight: bold;">try</span> <span style="color: #009900;">&#123;</span>
                   currentRange.<span style="color: #006633;">start</span> <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Along+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Long</span></a>.<span style="color: #006633;">parseLong</span>
                       <span style="color: #009900;">&#40;</span>rangeDefinition.<span style="color: #006633;">substring</span><span style="color: #009900;">&#40;</span><span style="color: #cc66cc;">0</span>, dashPos<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                   <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>dashPos <span style="color: #339933;">&lt;</span> rangeDefinition.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #009900;">&#41;</span>
                       currentRange.<span style="color: #006633;">end</span> <span style="color: #339933;">=</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Along+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">Long</span></a>.<span style="color: #006633;">parseLong</span>
                           <span style="color: #009900;">&#40;</span>rangeDefinition.<span style="color: #006633;">substring</span>
                            <span style="color: #009900;">&#40;</span>dashPos <span style="color: #339933;">+</span> <span style="color: #cc66cc;">1</span>, rangeDefinition.<span style="color: #006633;">length</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                   <span style="color: #000000; font-weight: bold;">else</span>
                       currentRange.<span style="color: #006633;">end</span> <span style="color: #339933;">=</span> fileLength <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
               <span style="color: #009900;">&#125;</span> <span style="color: #000000; font-weight: bold;">catch</span> <span style="color: #009900;">&#40;</span><a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Anumberformatexception+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">NumberFormatException</span></a> e<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
                   response.<span style="color: #006633;">addHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Range&quot;</span>,
                                      <span style="color: #0000ff;">&quot;bytes */&quot;</span> <span style="color: #339933;">+</span> fileLength<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                   response.<span style="color: #006633;">sendError</span>
                       <span style="color: #009900;">&#40;</span>HttpServletResponse
                        .<span style="color: #006633;">SC_REQUESTED_RANGE_NOT_SATISFIABLE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
                   <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
               <span style="color: #009900;">&#125;</span>
&nbsp;
           <span style="color: #009900;">&#125;</span>
&nbsp;
           <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span>currentRange.<span style="color: #006633;">validate</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>
               response.<span style="color: #006633;">addHeader</span><span style="color: #009900;">&#40;</span><span style="color: #0000ff;">&quot;Content-Range&quot;</span>, <span style="color: #0000ff;">&quot;bytes */&quot;</span> <span style="color: #339933;">+</span> fileLength<span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
               response.<span style="color: #006633;">sendError</span>
                   <span style="color: #009900;">&#40;</span>HttpServletResponse.<span style="color: #006633;">SC_REQUESTED_RANGE_NOT_SATISFIABLE</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
               <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #000066; font-weight: bold;">null</span><span style="color: #339933;">;</span>
           <span style="color: #009900;">&#125;</span>
&nbsp;
           result.<span style="color: #006633;">add</span><span style="color: #009900;">&#40;</span>currentRange<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;">return</span> result<span style="color: #339933;">;</span>
   <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #666666; font-style: italic;">// ------------------------------------------------------ Range Inner Class</span>
&nbsp;
&nbsp;
   <span style="color: #000000; font-weight: bold;">protected</span> <span style="color: #000000; font-weight: bold;">class</span> Range <span style="color: #009900;">&#123;</span>
&nbsp;
       <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">long</span> start<span style="color: #339933;">;</span>
       <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">long</span> end<span style="color: #339933;">;</span>
       <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">long</span> length<span style="color: #339933;">;</span>
&nbsp;
       <span style="color: #008000; font-style: italic; font-weight: bold;">/**
        * Validate range.
        */</span>
       <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">boolean</span> validate<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
           <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>end <span style="color: #339933;">&gt;=</span> length<span style="color: #009900;">&#41;</span>
               end <span style="color: #339933;">=</span> length <span style="color: #339933;">-</span> <span style="color: #cc66cc;">1</span><span style="color: #339933;">;</span>
           <span style="color: #000000; font-weight: bold;">return</span> <span style="color: #009900;">&#40;</span> <span style="color: #009900;">&#40;</span>start <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>end <span style="color: #339933;">&gt;=</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>start <span style="color: #339933;">&lt;</span> <span style="color: #339933;">=</span> end<span style="color: #009900;">&#41;</span>
                    <span style="color: #339933;">&amp;&amp;</span> <span style="color: #009900;">&#40;</span>length <span style="color: #339933;">&gt;</span> <span style="color: #cc66cc;">0</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span>
&nbsp;
       <span style="color: #000000; font-weight: bold;">public</span> <span style="color: #000066; font-weight: bold;">void</span> recycle<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
           start <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
           end <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
           length <span style="color: #339933;">=</span> <span style="color: #cc66cc;">0</span><span style="color: #339933;">;</span>
       <span style="color: #009900;">&#125;</span>
&nbsp;
   <span style="color: #009900;">&#125;</span>
<span style="color: #339933;">&lt;/</span>range<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.hitangjun.com/2011/12/16/how-does-java-process-interruption-resuming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MP3文件信息读取分析</title>
		<link>http://blog.hitangjun.com/2011/09/03/mp3-analysis/</link>
		<comments>http://blog.hitangjun.com/2011/09/03/mp3-analysis/#comments</comments>
		<pubDate>Sat, 03 Sep 2011 04:19:45 +0000</pubDate>
		<dc:creator>tj4c</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[mp3]]></category>

		<guid isPermaLink="false">http://blog.hitangjun.com/?p=2113</guid>
		<description><![CDATA[提取自yoyoplayer的MP3解析器可以读取MP3文件的信息，并利用百度获取MP3文件的歌词地址 java -jar mp3.jar -n “d:/KwDownload/song/刘德华-母亲.mp3&#8243; 输出： 使用方法： MP3Info mp3 = new MP3Info(“测试读取MP3&#8243;,”d:/KwDownload/song/刘德华-母亲.mp3&#8243;,-1,true); mp3.reRead(); mp3.isValid():true ====================================== 歌手mp3.getArtist() 刘德华 歌名mp3.getTitle() 母亲 专辑mp3.getAlbum() 格式化名称mp3.getFormattedDisplayName() 刘德华 &#8211; 母亲 格式化名称mp3.getFormattedName()刘德华 &#8211; 母亲 格式化参数mp3.getFormat()mp3 44kHz 192kbps 声道mp3.getChannelInfo()立体声 备注mp3.getComment() 类型mp3.getType()mp3 年份mp3.getYear() 采样率mp3.getSampled()44kHz 时长mp3.getFormattedLength()03:42 时长long型mp3.getLength()222 ====================================== ===============搜索歌词文件=========== %C1%F5%B5%C2%BB%AA+%C4%B8%C7%D7 size:1 歌曲：母亲 歌手：刘德华 下载地址：http://www.51lrcgc.com/asp/lrc.asp?id=20090917g9W6fF try http://download.csdn.net/source/3571532]]></description>
			<content:encoded><![CDATA[<p>提取自yoyoplayer的MP3解析器可以读取MP3文件的信息，并利用百度获取MP3文件的歌词地址<br />
java -jar mp3.jar -n “d:/KwDownload/song/刘德华-母亲.mp3&#8243; </p>
<p>输出：</p>
<p>使用方法：</p>
<p>MP3Info mp3 = new MP3Info(“测试读取MP3&#8243;,”d:/KwDownload/song/刘德华-母亲.mp3&#8243;,-1,true);<br />
mp3.reRead();</p>
<p>mp3.isValid():true</p>
<p>======================================<br />
歌手mp3.getArtist() 刘德华<br />
歌名mp3.getTitle() 母亲<br />
专辑mp3.getAlbum()<br />
格式化名称mp3.getFormattedDisplayName() 刘德华 &#8211; 母亲<br />
格式化名称mp3.getFormattedName()刘德华 &#8211; 母亲<br />
格式化参数mp3.getFormat()mp3 44kHz 192kbps<br />
声道mp3.getChannelInfo()立体声<br />
备注mp3.getComment()<br />
类型mp3.getType()mp3<br />
年份mp3.getYear()<br />
采样率mp3.getSampled()44kHz<br />
时长mp3.getFormattedLength()03:42<br />
时长long型mp3.getLength()222</p>
<p>======================================</p>
<p>===============搜索歌词文件===========<br />
%C1%F5%B5%C2%BB%AA+%C4%B8%C7%D7<br />
size:1<br />
歌曲：母亲<br />
歌手：刘德华<br />
下载地址：http://www.51lrcgc.com/asp/lrc.asp?id=20090917g9W6fF</p>
<p>try  <a href="http://download.csdn.net/source/3571532" title="http://download.csdn.net/source/3571532" target="_blank">http://download.csdn.net/source/3571532</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hitangjun.com/2011/09/03/mp3-analysis/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Oracle 表空间监控</title>
		<link>http://blog.hitangjun.com/2011/08/11/oracle-monitor-tablespace/</link>
		<comments>http://blog.hitangjun.com/2011/08/11/oracle-monitor-tablespace/#comments</comments>
		<pubDate>Thu, 11 Aug 2011 02:09:30 +0000</pubDate>
		<dc:creator>tj4c</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[oracle]]></category>

		<guid isPermaLink="false">http://blog.hitangjun.com/?p=2106</guid>
		<description><![CDATA[?View Code JAVAprivate final String QUERY_TABLE_SPACE_SQL = &#34;select nvl(b.tablespace_name,nvl(a.tablespace_name,'UNKNOWN')) name,&#34; + &#34; Mbytes_alloc-nvl(Mbytes_free,0) , nvl(Mbytes_free,0) , nvl(Maxfree_ext,0) , &#34; + &#34; ((Mbytes_alloc-nvl(Mbytes_free,0))/Mbytes_alloc)*100 pct_used from (select sum(bytes)/1024/1024 Mbytes_free ,&#34; + &#34;MAX(BYTES)/1024/1024 Maxfree_ext ,tablespace_name from dba_free_space group by tablespace_name) a ,&#34; + &#34; (select sum(bytes)/1024/1024 Mbytes_alloc , tablespace_name from dba_data_files group by tablespace_name) b&#34; + &#34; where [...]]]></description>
			<content:encoded><![CDATA[
<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2106code4'); return false;">View Code</a> JAVA</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p21064"><td class="code" id="p2106code4"><pre class="java" style="font-family:monospace;"><span style="color: #000000; font-weight: bold;">private</span> <span style="color: #000000; font-weight: bold;">final</span> <a href="http://www.google.com/search?hl=en&amp;q=allinurl%3Astring+java.sun.com&amp;btnI=I%27m%20Feeling%20Lucky"><span style="color: #003399;">String</span></a> QUERY_TABLE_SPACE_SQL <span style="color: #339933;">=</span> <span style="color: #0000ff;">&quot;select nvl(b.tablespace_name,nvl(a.tablespace_name,'UNKNOWN')) name,&quot;</span> <span style="color: #339933;">+</span>
			<span style="color: #0000ff;">&quot; Mbytes_alloc-nvl(Mbytes_free,0)    ,  nvl(Mbytes_free,0)   , nvl(Maxfree_ext,0) , &quot;</span> <span style="color: #339933;">+</span>
			<span style="color: #0000ff;">&quot;  ((Mbytes_alloc-nvl(Mbytes_free,0))/Mbytes_alloc)*100  pct_used from (select sum(bytes)/1024/1024   Mbytes_free  ,&quot;</span> <span style="color: #339933;">+</span>
			<span style="color: #0000ff;">&quot;MAX(BYTES)/1024/1024 Maxfree_ext ,tablespace_name from   dba_free_space group by tablespace_name)   a ,&quot;</span> <span style="color: #339933;">+</span>
			<span style="color: #0000ff;">&quot; (select  sum(bytes)/1024/1024 Mbytes_alloc ,  tablespace_name from  dba_data_files group by tablespace_name)   b&quot;</span> <span style="color: #339933;">+</span>
			<span style="color: #0000ff;">&quot; where a.tablespace_name (+) = b.tablespace_name and upper(nvl(b.tablespace_name,nvl(a.tablespace_name,'UNKNOWN'))) &quot;</span> <span style="color: #339933;">+</span>
			<span style="color: #0000ff;">&quot;in (:tableSpaceNames) order by name&quot;</span><span style="color: #339933;">;</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://blog.hitangjun.com/2011/08/11/oracle-monitor-tablespace/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>JsTree Demo</title>
		<link>http://blog.hitangjun.com/2011/08/10/jstree-demo/</link>
		<comments>http://blog.hitangjun.com/2011/08/10/jstree-demo/#comments</comments>
		<pubDate>Wed, 10 Aug 2011 05:06:21 +0000</pubDate>
		<dc:creator>tj4c</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[jQuery]]></category>
		<category><![CDATA[JsTree]]></category>

		<guid isPermaLink="false">http://blog.hitangjun.com/?p=2098</guid>
		<description><![CDATA[JsTree Demo Version: jstree pre 1.0 stable Old versions: http://code.google.com/p/jstree/downloads/list Add a demo for jstree in demo/index.html Integrate the usage of metadata, click the node event ,attrs,toggle nodes and ajax json in jstree Changed apple theme and classic theme background fixed for in ie6. 1. ?View Code HTML&#60;script type=&#34;text/javascript&#34; src=&#34;./_lib/jquery.js&#34;&#62;&#60;/script&#62; &#60;script type=&#34;text/javascript&#34; src=&#34;./jquery.jstree.js&#34;&#62;&#60;/script&#62; 2. ?View [...]]]></description>
			<content:encoded><![CDATA[<div id="_mcePaste">
<div id="_mcePaste">JsTree Demo</div>
<div id="_mcePaste">Version: jstree pre 1.0 stable</div>
<div id="_mcePaste">Old versions:<a title=" http://code.google.com/p/jstree/downloads/list" href=" http://code.google.com/p/jstree/downloads/list" target="_blank"> http://code.google.com/p/jstree/downloads/list</a></div>
<div id="_mcePaste">Add a demo for jstree in demo/index.html</div>
<div id="_mcePaste"><strong>Integrate the usage of metadata, click the node event ,attrs,toggle nodes and ajax json in jstree</strong></div>
<div id="_mcePaste"><strong>Changed apple theme and classic theme background fixed for in ie6.</strong></div>
<p>1.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2098code7'); return false;">View Code</a> HTML</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p20987"><td class="code" id="p2098code7"><pre class="html" style="font-family:monospace;">&lt;script type=&quot;text/javascript&quot; src=&quot;./_lib/jquery.js&quot;&gt;&lt;/script&gt;
&lt;script type=&quot;text/javascript&quot; src=&quot;./jquery.jstree.js&quot;&gt;&lt;/script&gt;</pre></td></tr></table></div>

<p>2.</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p2098code8'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p20988"><td class="code" id="p2098code8"><pre class="javascript" style="font-family:monospace;"><span style="color: #339933;">&lt;</span>script type<span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;text/javascript&quot;</span> <span style="color: #003366; font-weight: bold;">class</span><span style="color: #339933;">=</span><span style="color: #3366CC;">&quot;source below&quot;</span><span style="color: #339933;">&gt;</span>
$<span style="color: #009900;">&#40;</span><span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	$.<span style="color: #660066;">ajaxSetup</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>cache<span style="color: #339933;">:</span><span style="color: #003366; font-weight: bold;">false</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span><span style="color: #006600; font-style: italic;">//ajax request don't use the cache</span>
$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#jsonDemo&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">jstree</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span> 
		<span style="color: #006600; font-style: italic;">// List of active plugins</span>
		<span style="color: #3366CC;">&quot;plugins&quot;</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span> 
			<span style="color: #3366CC;">&quot;themes&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;json_data&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;ui&quot;</span>
		<span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
		<span style="color: #006600; font-style: italic;">// I usually configure the plugin that handles the data first</span>
		<span style="color: #006600; font-style: italic;">// This example uses JSON as it is most common</span>
		<span style="color: #3366CC;">&quot;json_data&quot;</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> 
			<span style="color: #3366CC;">&quot;data&quot;</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#91;</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;attr&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;1204&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;isLast&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;false&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;A Node&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
				          <span style="color: #3366CC;">&quot;data&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;A Node&quot;</span><span style="color: #339933;">,</span>
				         <span style="color: #3366CC;">&quot;metadata&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;1204&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;isLast&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;false&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;A Node&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
				          <span style="color: #3366CC;">&quot;state&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;closed&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
			          <span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;attr&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;1205&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;isLast&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;true&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;B Node&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
			          	<span style="color: #3366CC;">&quot;data&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;B Node&quot;</span><span style="color: #339933;">,</span>
			          	<span style="color: #3366CC;">&quot;metadata&quot;</span><span style="color: #339933;">:</span><span style="color: #009900;">&#123;</span><span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;1205&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;isLast&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;true&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;B Node&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>
			          	<span style="color: #3366CC;">&quot;state&quot;</span><span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;close&quot;</span><span style="color: #009900;">&#125;</span>
			         <span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span>
			<span style="color: #3366CC;">&quot;ajax&quot;</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span> <span style="color: #3366CC;">&quot;url&quot;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;./_demo/_tree_json.json&quot;</span><span style="color: #339933;">,</span>
						     <span style="color: #3366CC;">&quot;data&quot;</span><span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>n<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>
	                            <span style="color: #000066; font-weight: bold;">return</span><span style="color: #009900;">&#123;</span>
 	                                <span style="color: #006600; font-style: italic;">//set the url request param,multi param separate by ,</span>
			                            <span style="color: #3366CC;">&quot;parentId&quot;</span> <span style="color: #339933;">:</span> n.<span style="color: #660066;">attr</span> <span style="color: #339933;">?</span> n.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;null&quot;</span><span style="color: #339933;">,</span>
			                            <span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #339933;">:</span>  n.<span style="color: #660066;">attr</span> <span style="color: #339933;">?</span> n.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;name&quot;</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;null&quot;</span>
	                            <span style="color: #009900;">&#125;</span><span style="color: #339933;">;</span>
                        <span style="color: #009900;">&#125;</span>
			 <span style="color: #009900;">&#125;</span>
		<span style="color: #009900;">&#125;</span><span style="color: #339933;">,</span>	
	   <span style="color: #3366CC;">&quot;themes&quot;</span> <span style="color: #339933;">:</span> <span style="color: #009900;">&#123;</span>
	         <span style="color: #3366CC;">&quot;theme&quot;</span> <span style="color: #339933;">:</span> <span style="color: #3366CC;">&quot;classic&quot;</span><span style="color: #339933;">,</span> <span style="color: #006600; font-style: italic;">//apple,default,if in ie6 recommented you use classic</span>
	         <span style="color: #3366CC;">&quot;dots&quot;</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span><span style="color: #339933;">,</span>
	         <span style="color: #3366CC;">&quot;icons&quot;</span> <span style="color: #339933;">:</span> <span style="color: #003366; font-weight: bold;">true</span>
	   <span style="color: #009900;">&#125;</span>
	<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
	.<span style="color: #660066;">bind</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;select_node.jstree&quot;</span><span style="color: #339933;">,</span><span style="color: #003366; font-weight: bold;">function</span><span style="color: #009900;">&#40;</span>event<span style="color: #339933;">,</span>data<span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span>  
			<span style="color: #000066; font-weight: bold;">if</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;true&quot;</span> <span style="color: #339933;">==</span> data.<span style="color: #660066;">rslt</span>.<span style="color: #660066;">obj</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;isLast&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#123;</span> 
				 <span style="color: #006600; font-style: italic;">//get the attrs data you set in the attrs field;</span>
			    <span style="color: #000066;">alert</span><span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">rslt</span>.<span style="color: #660066;">obj</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">+</span>data.<span style="color: #660066;">rslt</span>.<span style="color: #660066;">obj</span>.<span style="color: #660066;">attr</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;isLast&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			    <span style="color: #006600; font-style: italic;">//you can do something here...</span>
			<span style="color: #009900;">&#125;</span><span style="color: #000066; font-weight: bold;">else</span><span style="color: #009900;">&#123;</span>
				<span style="color: #006600; font-style: italic;">//toggle node refer to the id setted in the metadata</span>
				<span style="color: #006600; font-style: italic;">//get the metadata id field value : jQuery.data(data.rslt.obj[0], &quot;id&quot;)；</span>
				<span style="color: #006600; font-style: italic;">//The metadata id value should be different to each other !!!</span>
				<span style="color: #006600; font-style: italic;">//otherwise, the toggle_node will work incorrect !!!</span>
				$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#jsonDemo&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">jstree</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;toggle_node&quot;</span><span style="color: #339933;">,</span><span style="color: #3366CC;">&quot;#&quot;</span><span style="color: #339933;">+</span>jQuery.<span style="color: #660066;">data</span><span style="color: #009900;">&#40;</span>data.<span style="color: #660066;">rslt</span>.<span style="color: #660066;">obj</span><span style="color: #009900;">&#91;</span><span style="color: #CC0000;">0</span><span style="color: #009900;">&#93;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;id&quot;</span><span style="color: #009900;">&#41;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
			<span style="color: #009900;">&#125;</span>    
    <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
    <span style="color: #006600; font-style: italic;">// prevent the default event of the link </span>
	.<span style="color: #660066;">delegate</span><span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;a&quot;</span><span style="color: #339933;">,</span> <span style="color: #3366CC;">&quot;click&quot;</span><span style="color: #339933;">,</span> <span style="color: #003366; font-weight: bold;">function</span> <span style="color: #009900;">&#40;</span>event<span style="color: #339933;">,</span> data<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> event.<span style="color: #660066;">preventDefault</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span> <span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span>
	<span style="color: #339933;">;</span>
<span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
<span style="color: #339933;">&lt;/</span>script<span style="color: #339933;">&gt;</span></pre></td></tr></table></div>

<div>
demo page:<a title="http://johntang.github.com/JsTree/" href="http://johntang.github.com/JsTree/" target="_blank">http://johntang.github.com/JsTree/</a><br />
<a title="http://johntang.github.com/JsTree/" href="http://johntang.github.com/JsTree/" target="_blank"></a>Integrate demo page:<a title="http://johntang.github.com/JsTree/demo.html" href="http://johntang.github.com/JsTree/demo.html" target="_blank">http://johntang.github.com/JsTree/demo.html</a>
</div>
<div id="_mcePaste">Jstree demo page:<a title="http://johntang.github.com/JsTree/_demo/" href="http://johntang.github.com/JsTree/_demo/" target="_blank">http://johntang.github.com/JsTree/_demo/</a></div>
</div>
]]></content:encoded>
			<wfw:commentRss>http://blog.hitangjun.com/2011/08/10/jstree-demo/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>custome metro response schema prefix</title>
		<link>http://blog.hitangjun.com/2011/04/25/custome-metro-response-schema-prefix/</link>
		<comments>http://blog.hitangjun.com/2011/04/25/custome-metro-response-schema-prefix/#comments</comments>
		<pubDate>Mon, 25 Apr 2011 06:10:19 +0000</pubDate>
		<dc:creator>tj4c</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[metro]]></category>

		<guid isPermaLink="false">http://blog.hitangjun.com/?p=2092</guid>
		<description><![CDATA[Question: Metro for SOAP web services, In the response, the namespace prefixes are ns2, ns3, ns4, and so on. I&#8217;d like to be able to instruct the web services stack to use custom names instead. To solve this, please do as follow: 1 In the response/request bean package,named a package-info.java 2 set the annotation like [...]]]></description>
			<content:encoded><![CDATA[<blockquote><p>Question: Metro for SOAP web services, In the response, the namespace prefixes are ns2, ns3, ns4, and so on. I&#8217;d like to be able to instruct the web services stack to use custom names instead.</p></blockquote>
<p>To solve this, please do as follow:<br />
1 In the response/request bean package,named a package-info.java<br />
2 set the annotation like<br />
<code><br />
@javax.xml.bind.annotation.XmlSchema(xmlns = {<br />
@XmlNs(prefix = "fixml",<br />
namespaceURI= "http://www.fixprotocol.org/FIXML-5-0-SP2")},<br />
elementFormDefault = javax.xml.bind.annotation.XmlNsForm.QUALIFIED<br />
)<br />
package org.fixprotocol.fixml_5_0_sp2;<br />
import javax.xml.bind.annotation.XmlNs;<br />
</code></p>
<p>keyword:<br />
<code><br />
prefix = "fixml",<br />
namespaceURI= "http://www.fixprotocol.org/FIXML-5-0-SP2"</code></p>
<p>you can replace this keyword as you want.<br />
the result is</p>
<blockquote>
<div id="_mcePaste">&lt;soapenv:envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/”  xmlns:fixml=”http://www.fixprotocol.org/FIXML-5-0-SP2&#8243;&gt;</div>
<div id="_mcePaste">&lt;/soapenv:envelope&gt;</div>
<p>&lt;soapenv:envelope xmlns:soapenv=”http://schemas.xmlsoap.org/soap/envelope/”  xmlns:fixml=”http://www.fixprotocol.org/FIXML-5-0-SP2&#8243;&gt;&lt;/soapenv:envelope&gt;</p></blockquote>
<p>according the Metro Schema Validation guide <a href="http://metro.java.net/guide/Schema_Validation.html">http://metro.java.net/guide/Schema_Validation.html</a><br />
we can implement the request and response soap message scheme validation.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hitangjun.com/2011/04/25/custome-metro-response-schema-prefix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Java 串口曲线程序</title>
		<link>http://blog.hitangjun.com/2010/08/08/java-serial-port-program/</link>
		<comments>http://blog.hitangjun.com/2010/08/08/java-serial-port-program/#comments</comments>
		<pubDate>Sun, 08 Aug 2010 06:23:42 +0000</pubDate>
		<dc:creator>tj4c</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[串口通信]]></category>

		<guid isPermaLink="false">http://blog.hitangjun.com/?p=1315</guid>
		<description><![CDATA[Java 串口曲线程序 设计需求 1. 能够接受下位机数据。 2. 保存接受的数据。 3. 把接收到合法的数据形成曲线。 4. 能够发送数据。 5. 程序能够设置常用串口参数。 6. 程序可以探测数据点的数据。 截图 功能实现基于 Java串口通信RXTX JfreeChart实现数据的实时动态曲线显示 串口模拟程序VSPD使用 http://www.bzhou.com/shuma/200812/20-9476.html 下载VSPD http://d.download.csdn.net/down/2605714/tangjunchf 附件是所有的源码程序，未整理，具体实现逻辑有删改 下载源码http://d.download.csdn.net/down/2605710/tangjunchf]]></description>
			<content:encoded><![CDATA[<p>Java 串口曲线程序</p>
<blockquote><p>设计需求<br />
   1. 能够接受下位机数据。<br />
   2. 保存接受的数据。<br />
   3. 把接收到合法的数据形成曲线。<br />
   4. 能够发送数据。<br />
   5. 程序能够设置常用串口参数。<br />
   6. 程序可以探测数据点的数据。</p></blockquote>
<p>截图<br />
<a href="http://hitangjun.com" title="serialPort"><img src="http://farm5.static.flickr.com/4075/4870521857_507ab1670d.jpg" width="500" height="348" alt="serialPort" /></a></p>
<p>功能实现基于<br />
<a href="http://blog.hitangjun.com/2010/08/08/java-serial-port-rxtx/">Java串口通信RXTX </a></p>
<p><a href=" http://blog.hitangjun.com/2010/08/08/jfreechart-dynamic-xychart/">JfreeChart实现数据的实时动态曲线显示</a></p>
<p>串口模拟程序VSPD使用<a href=" http://www.bzhou.com/shuma/200812/20-9476.html"> http://www.bzhou.com/shuma/200812/20-9476.html</a><br />
下载VSPD<a href=" http://d.download.csdn.net/down/2605714/tangjunchf"> http://d.download.csdn.net/down/2605714/tangjunchf</a></p>
<p>附件是所有的源码程序，未整理，具体实现逻辑有删改<br />
下载源码<a href="http://d.download.csdn.net/down/2605710/tangjunchf">http://d.download.csdn.net/down/2605710/tangjunchf</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hitangjun.com/2010/08/08/java-serial-port-program/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>Java串口通信RXTX</title>
		<link>http://blog.hitangjun.com/2010/08/08/java-serial-port-rxtx/</link>
		<comments>http://blog.hitangjun.com/2010/08/08/java-serial-port-rxtx/#comments</comments>
		<pubDate>Sun, 08 Aug 2010 05:40:43 +0000</pubDate>
		<dc:creator>tj4c</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[RXTX]]></category>
		<category><![CDATA[串口通信]]></category>

		<guid isPermaLink="false">http://blog.hitangjun.com/?p=1311</guid>
		<description><![CDATA[Java串口通信RXTX RXTX是个提供串口和并口通信的开源java类库，由该项目发布的文档均遵循LGPL协议。该项目的主页位于 http://users.frii.com/jarvi/rxtx/index.html。 　　RXTX项目提供了Windows,Linux,Mac os X,Solaris操作系统下的兼容javax.comm串口通讯包API的实现，为其他研发人员在此类系统下研发串口应用提供了相当的方便。 这里是他的WIKI主页 http://rxtx.qbang.org/wiki/index.php/Main_Page 下载 http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip 在WINDOWS上安装 http://rxtx.qbang.org/wiki/index.php/Installation_on_MS-Windows 使用RXTX Examples * Two way communcation with the serial port * Event based two way Communication * Parallel Communications * Discovering comm ports * Discovering available comm ports * Writing “Hello World” to a USB to serial converter 在eclipse里如何使用RXTX呢？ This is how I [...]]]></description>
			<content:encoded><![CDATA[<p>Java串口通信RXTX</p>
<p>RXTX是个提供串口和并口通信的开源java类库，由该项目发布的文档均遵循LGPL协议。该项目的主页位于 <a href="http://users.frii.com/jarvi/rxtx/index.html">http://users.frii.com/jarvi/rxtx/index.html</a>。<br />
　　RXTX项目提供了Windows,Linux,Mac os X,Solaris操作系统下的兼容javax.comm串口通讯包API的实现，为其他研发人员在此类系统下研发串口应用提供了相当的方便。</p>
<p>这里是他的WIKI主页<br />
<a href="http://rxtx.qbang.org/wiki/index.php/Main_Page">http://rxtx.qbang.org/wiki/index.php/Main_Page</a></p>
<p>下载<br />
<a href="http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip">http://rxtx.qbang.org/pub/rxtx/rxtx-2.1-7-bins-r2.zip</a></p>
<p>在WINDOWS上安装<br />
<a href="http://rxtx.qbang.org/wiki/index.php/Installation_on_MS-Windows">http://rxtx.qbang.org/wiki/index.php/Installation_on_MS-Windows</a></p>
<p>使用RXTX</p>
<p>Examples<br />
    * <a href=" http://rxtx.qbang.org/wiki/index.php/Two_way_communcation_with_the_serial_port">Two way communcation with the serial port </a><br />
    * <a href=" http://rxtx.qbang.org/wiki/index.php/Event_based_two_way_Communication">Event based two way Communication</a><br />
    * <a href="http://rxtx.qbang.org/wiki/index.php/Parallel_Communications">Parallel Communications </a><br />
    * <a href="http://rxtx.qbang.org/wiki/index.php/Discovering_comm_ports">Discovering comm ports</a><br />
    * <a href="http://rxtx.qbang.org/wiki/index.php/Discovering_available_comm_ports">Discovering available comm ports </a><br />
    * <a href="http://rxtx.qbang.org/wiki/index.php/Writing_%22Hello_World%22_to_a_USB_to_serial_converter">Writing “Hello World” to a USB to serial converter </a></p>
<p>在eclipse里如何使用RXTX呢？</p>
<p>This is how I add and use RXTX in Eclipse for Win32 Projects, there are probably other ways but it works for me. [1]</p>
<blockquote><p>   1. Copy RXTXcomm.jar, rxtxSerial.dll and rxtxParallel.dll files to the lib directory of your project<br />
   复制RXTXcomm.jar, rxtxSerial.dll 和 rxtxParallel.dll文件到项目lib文件夹<br />
   2. Under Project | Properties | Java Build Path | Libraries<br />
   3. click Add JARs&#8230; Button<br />
   在工程属性下将lib包加入项目编译路径<br />
   4. Select the RXTXComm.jar from lib directory<br />
   5. Jar should now be in the Build Path<br />
   6. expand the RXTXComm.jar entry in the list and select “Native Library Location”<br />
   添加后，单击RXTXComm.jar展开,选择Native Library Location,选中rxtxSerial.dll 和 rxtxParallel.dll所在的目录，然后应用修改,OK。<br />
   7. Select the project lib directory and apply </p></blockquote>
<p><strong><a href="http://d.download.csdn.net/down/2605644/tangjunchf">附件</a>里有WIKI上所有的源码，另外com.hitangjun.rxtx.util.demo包下有一个基于RXTX应用的实例，使用的是观察者模式</strong></p>
<p>不是很明白RXTX是如何和串口通信的，串口的设置参数是如何应用，以及是如何处理收发数据的。 </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hitangjun.com/2010/08/08/java-serial-port-rxtx/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>JfreeChart实现数据的实时动态曲线显示</title>
		<link>http://blog.hitangjun.com/2010/08/08/jfreechart-dynamic-xychart/</link>
		<comments>http://blog.hitangjun.com/2010/08/08/jfreechart-dynamic-xychart/#comments</comments>
		<pubDate>Sun, 08 Aug 2010 04:35:43 +0000</pubDate>
		<dc:creator>tj4c</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[jfreechart]]></category>

		<guid isPermaLink="false">http://blog.hitangjun.com/?p=1307</guid>
		<description><![CDATA[目标： 通过JfreeChart实现数据的实时动态曲线显示 需要解决的问题 JfreeChart如何生成折线图？ JfreeChart如何生成动态图？ 如何改变JfreeChart的动态图的X轴？ JfreeChart如何生成折线图？ JfreeChart提供了一个MemoryUsage的demo, 配置开发环境 下载Jfreechart的lib包 http://sourceforge.net/projects/jfreechart/files/ 创建eclipse工程，引入jcommon-*.jar,jfreechart-*.jar MemoryUsage的源码可以在下面的打包文件里找到 将这个demo运行起来你就可以看到一个JVM 内存消耗的实时数据显示 分析源码后可以发现生成这样的图表主要用到了 org.jfree.data.time.TimeSeriesCollection org.jfree.data.time.TimeSeries 这个主要的功能是实时的收集数据，API文档是这样描述的 A collection of time series objects. This class implements the XYDataset interface, as well as the extended IntervalXYDataset interface. This makes it a convenient dataset for use with the XYPlot class. org.jfree.chart.plot.XYPlot 是一个曲线图，通过指定XY的坐标来表示数据点，任何实现了XYDataset接口的类都可以通过它来显示， 它通过XYItemRenderer来设置点数据的显示样式，从而生成各种不同的图表。 A general [...]]]></description>
			<content:encoded><![CDATA[<p><strong>目标：</strong><br />
 通过JfreeChart实现数据的实时动态曲线显示</p>
<p><strong> 需要解决的问题</strong><br />
 JfreeChart如何生成折线图？<br />
 JfreeChart如何生成动态图？<br />
 如何改变JfreeChart的动态图的X轴？</p>
<p>JfreeChart如何生成折线图？<br />
  JfreeChart提供了一个MemoryUsage的demo,</p>
<p><strong>配置开发环境</strong><br />
下载Jfreechart的lib包<a href=" http://sourceforge.net/projects/jfreechart/files/"> http://sourceforge.net/projects/jfreechart/files/</a><br />
创建eclipse工程，引入jcommon-*.jar,jfreechart-*.jar<br />
MemoryUsage的源码可以在下面的打包文件里找到<br />
将这个demo运行起来你就可以看到一个JVM 内存消耗的实时数据显示</p>
<p>分析源码后可以发现生成这样的图表主要用到了<br />
org.jfree.data.time.TimeSeriesCollection<br />
org.jfree.data.time.TimeSeries<br />
这个主要的功能是实时的收集数据，API文档是这样描述的<br />
A collection of time series objects.<br />
This class implements the XYDataset interface,<br />
as well as the extended IntervalXYDataset  interface.<br />
This makes it a convenient dataset for use with the XYPlot class.</p>
<p>org.jfree.chart.plot.XYPlot<br />
是一个曲线图，通过指定XY的坐标来表示数据点，任何实现了XYDataset接口的类都可以通过它来显示，<br />
它通过XYItemRenderer来设置点数据的显示样式，从而生成各种不同的图表。<br />
A general class for plotting data in the form of (x, y) pairs.<br />
This plot can use data from any class that implements the XYDataset interface.<br />
XYPlot makes use of an XYItemRenderer to draw each point on the plot.<br />
By using different renderers, various chart types can be produced. </p>
<p>问题<br />
现在X轴是以时间线来显示的，可以设置以刻度或次序(1,2,3,4&#8230;)的格式显示吗？<br />
可以，<br />
将<br />
org.jfree.data.time.TimeSeries<br />
org.jfree.data.time.TimeSeriesCollection<br />
换成<br />
org.jfree.data.xy.XYSeries<br />
org.jfree.data.xy.XYSeriesCollection<br />
就可以了。</p>
<p>那他们还是动态的图吗？<br />
是的。</p>
<p><strong>那是为什么呢？<br />
因为XYSeriesCollection 和 TimeSeriesCollection都实现了这样一个接口<br />
org.jfree.data.general.SeriesChangeListener<br />
它继承自EventListener<br />
SeriesChangeListener extends java.util.EventListener<br />
它有定义了数据更改时发出通知的方法</strong><br />
Methods for receiving notification of changes to a data series.</p>
<p>void 	seriesChanged(SeriesChangeEvent event)<br />
     Called when an observed series changes in some way.</p>
<p><strong>实现了这个接口的SeriesCollection都可以实时的更新数据<br />
添加数据可以使用<br />
series.add(X,Y);<br />
更新可以使用<br />
series.update(X,Y);<br />
还有清空之前的所有数据可以使用<br />
series.clear();</strong></p>
<p><strong>如何实时的显示特定点的数据呢？</strong><br />
当然JfreeChart有一个tip的功能，当鼠标移上去的时候显示数据点的数据<br />
但是如何让它按照我们想要的格式显示呢？</p>
<p>这里你就需要使用<br />
org.jfree.chart.annotations.XYTextAnnotation</p>
<p>A text annotation that can be placed at a particular (x, y) location on an XYPlot. </p>
<p>这里有一小段的代码(更多的jfreechart的demo代码可以在附件里找到，相信看过之后，基本上都能满足你的要求了)</p>
<p>XYTextAnnotation textpointer = new XYTextAnnotation(X+”,”+Y,  X+15, Y-15);<br />
textpointer.setBackgroundPaint(Color.YELLOW);<br />
textpointer.setPaint(Color.CYAN);<br />
dynamicJfreeChart.getXYPlot().addAnnotation(textpointer);</p>
<p>下面的代码未整理，收集来源于网络</p>
<p><a href="http://d.download.csdn.net/down/2605527/tangjunchf" target="_blank">http://d.download.csdn.net/down/2605527/tangjunchf</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hitangjun.com/2010/08/08/jfreechart-dynamic-xychart/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>SVN auto property</title>
		<link>http://blog.hitangjun.com/2010/07/19/svn-auto-property/</link>
		<comments>http://blog.hitangjun.com/2010/07/19/svn-auto-property/#comments</comments>
		<pubDate>Mon, 19 Jul 2010 02:37:17 +0000</pubDate>
		<dc:creator>tj4c</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://blog.hitangjun.com/?p=1213</guid>
		<description><![CDATA[通过svn的auto property keyword这一特性可以自动设置常用的文档信息，比如作者，时间，版本号等 修改配置文件 C:\Documents and Settings\Administrator\Application Data\Subversion\config 去掉注释开启auto propery特性 enable-auto-props = yes 添加 *.java = svn:mime-type=text/plain;svn:eol-style=native;svn:keywords=Date Revision Id Author 这样就可以在你提交JAVA文件到SVN时自动为其设置相应信息 /** * * @author $Author: $ * @version $Revision: $ * @since $Date: $ */ 配合TortoiseSVN 来配置会更好。]]></description>
			<content:encoded><![CDATA[<p>通过svn的auto property keyword这一特性可以自动设置常用的文档信息，比如作者，时间，版本号等</p>
<p>修改配置文件<br />
C:\Documents and Settings\Administrator\Application Data\Subversion\config<br />
去掉注释开启auto propery特性<br />
enable-auto-props = yes<br />
添加<br />
*.java = svn:mime-type=text/plain;svn:eol-style=native;svn:keywords=Date Revision Id Author</p>
<p>这样就可以在你提交JAVA文件到SVN时自动为其设置相应信息</p>
<p>/**<br />
 *<br />
 * @author $Author: $<br />
 * @version $Revision: $<br />
 * @since $Date: $<br />
 */</p>
<p>配合TortoiseSVN 来配置会更好。</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.hitangjun.com/2010/07/19/svn-auto-property/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>thickbox IE 不居中的问题</title>
		<link>http://blog.hitangjun.com/2010/04/28/thickbox-ie-not-align-center/</link>
		<comments>http://blog.hitangjun.com/2010/04/28/thickbox-ie-not-align-center/#comments</comments>
		<pubDate>Wed, 28 Apr 2010 08:15:45 +0000</pubDate>
		<dc:creator>tj4c</dc:creator>
				<category><![CDATA[IT技术]]></category>
		<category><![CDATA[thickbox]]></category>

		<guid isPermaLink="false">http://blog.hitangjun.com/?p=458</guid>
		<description><![CDATA[thickbox 3 是一个Jquery的插件,可以实现popup的效果,很漂亮，可是在IE下始终有一些兼容性的问题。 对于IE6或IE7下popup后不居中，可以通过修改下面的thickbox.js中的tb_position()方法，修改为如下内容即可 ?View Code JAVASCRIPTfunction tb_position&#40;&#41; &#123; $&#40;&#34;#TB_window&#34;&#41;.css&#40;&#123;marginLeft:&#34;-&#34; + parseInt&#40;&#40;TB_WIDTH / 2&#41;, 10&#41; + &#34;px&#34;, width:TB_WIDTH + &#34;px&#34;&#125;&#41;; var version = $.browser.version; if &#40;version instanceof Object&#41; &#123; version = version.number&#40;&#41;; &#125; var isIE=!!window.ActiveXObject; var isIE6=isIE&#38;&#38;!window.XMLHttpRequest; if &#40;!&#40;$.browser.msie &#38;&#38; version &#60; 7&#41; &#124;&#124; &#40;isIE &#38;&#38; !isIE6&#41; &#41; &#123; // take away IE6 $&#40;&#34;#TB_window&#34;&#41;.css&#40;&#123;marginTop:&#34;-&#34; + [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://jquery.com/demo/thickbox/">thickbox 3 </a>是一个Jquery的插件,可以实现popup的效果,很漂亮，可是在IE下始终有一些兼容性的问题。</p>
<p>对于IE6或IE7下popup后不居中，可以通过修改下面的thickbox.js中的tb_position()方法，修改为如下内容即可</p>

<div class="wp_codebox_msgheader"><span class="right"><sup><a href="http://www.ericbess.com/ericblog/2008/03/03/wp-codebox/#examples" target="_blank" title="WP-CodeBox HowTo?"><span style="color: #99cc00">?</span></a></sup></span><span class="left"><a href="javascript:;" onclick="javascript:showCodeTxt('p458code10'); return false;">View Code</a> JAVASCRIPT</span><div class="codebox_clear"></div></div><div class="wp_codebox"><table><tr id="p45810"><td class="code" id="p458code10"><pre class="javascript" style="font-family:monospace;"><span style="color: #003366; font-weight: bold;">function</span> tb_position<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
	$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#TB_window&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>marginLeft<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;-&quot;</span> <span style="color: #339933;">+</span> parseInt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>TB_WIDTH <span style="color: #339933;">/</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #339933;">,</span> width<span style="color: #339933;">:</span>TB_WIDTH <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> version <span style="color: #339933;">=</span> $.<span style="color: #660066;">browser</span>.<span style="color: #660066;">version</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span>version <span style="color: #000066; font-weight: bold;">instanceof</span> Object<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span>
		version <span style="color: #339933;">=</span> version.<span style="color: #660066;">number</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
	<span style="color: #003366; font-weight: bold;">var</span> isIE<span style="color: #339933;">=!!</span>window.<span style="color: #660066;">ActiveXObject</span><span style="color: #339933;">;</span>
	<span style="color: #003366; font-weight: bold;">var</span> isIE6<span style="color: #339933;">=</span>isIE<span style="color: #339933;">&amp;&amp;!</span>window.<span style="color: #660066;">XMLHttpRequest</span><span style="color: #339933;">;</span>
	<span style="color: #000066; font-weight: bold;">if</span> <span style="color: #009900;">&#40;</span><span style="color: #339933;">!</span><span style="color: #009900;">&#40;</span>$.<span style="color: #660066;">browser</span>.<span style="color: #660066;">msie</span> <span style="color: #339933;">&amp;&amp;</span> version <span style="color: #339933;">&lt;</span> <span style="color: #CC0000;">7</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">||</span> <span style="color: #009900;">&#40;</span>isIE <span style="color: #339933;">&amp;&amp;</span> <span style="color: #339933;">!</span>isIE6<span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#41;</span> <span style="color: #009900;">&#123;</span> <span style="color: #006600; font-style: italic;">// take away IE6</span>
		$<span style="color: #009900;">&#40;</span><span style="color: #3366CC;">&quot;#TB_window&quot;</span><span style="color: #009900;">&#41;</span>.<span style="color: #660066;">css</span><span style="color: #009900;">&#40;</span><span style="color: #009900;">&#123;</span>marginTop<span style="color: #339933;">:</span><span style="color: #3366CC;">&quot;-&quot;</span> <span style="color: #339933;">+</span> parseInt<span style="color: #009900;">&#40;</span><span style="color: #009900;">&#40;</span>TB_HEIGHT <span style="color: #339933;">/</span> <span style="color: #CC0000;">2</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">,</span> <span style="color: #CC0000;">10</span><span style="color: #009900;">&#41;</span> <span style="color: #339933;">+</span> <span style="color: #3366CC;">&quot;px&quot;</span><span style="color: #009900;">&#125;</span><span style="color: #009900;">&#41;</span><span style="color: #339933;">;</span>
	<span style="color: #009900;">&#125;</span>
<span style="color: #009900;">&#125;</span></pre></td></tr></table></div>

<p>另外对于IE下，CSS文件的重复引入也会引起问题。</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.hitangjun.com/2010/04/28/thickbox-ie-not-align-center/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

