??xml version="1.0" encoding="utf-8" standalone="yes"?>99精品偷自拍,国产精品黄色,成人免费看视频网站http://www.aygfsteel.com/RomKK/category/24356.htmlxjava技?zh-cnFri, 27 Jul 2007 04:22:08 GMTFri, 27 Jul 2007 04:22:08 GMT60桌面Java瘦n 注重Ajax特征http://www.aygfsteel.com/RomKK/archive/2007/07/26/132446.htmlRomKKRomKKThu, 26 Jul 2007 01:49:00 GMThttp://www.aygfsteel.com/RomKK/archive/2007/07/26/132446.htmlhttp://www.aygfsteel.com/RomKK/comments/132446.htmlhttp://www.aygfsteel.com/RomKK/archive/2007/07/26/132446.html#Feedback0http://www.aygfsteel.com/RomKK/comments/commentRss/132446.htmlhttp://www.aygfsteel.com/RomKK/services/trackbacks/132446.html

Z桌面Java的未来发展,许多的重大改q正在进行中Q对此做了很大的努力

  pa斚w来说Q出CJavaFX script 目?/span>JavaFX是很灵y的,它提供了一个高U的脚本接口Q运行在Java 2D?/span>API上。从用户的角度来看,他们不需要编?/span>Java代码Q不需要深入理解复杂的U程Q?/span>Java 2DQ?/span>Swingcȝ层次l构Q定时框架结?/span>(timing framework){等。相反,他们只是~写脚本语言和描l出所需要的GUIQ包括活波的韛_效果Q图形效果,比如说梯度或者音乐,和数据绑定等{,q些都徏立在一个基API上?/span>

  q里有许多的工具帮助你学?/span>syntax语言Q相兌源这个从q个|站获得;JavaFX研发组的目标就是提?/span>syntax语言Q和一些关?/span>JavaFX的用户体验,q些用户包括术设计员和那些对应用程序可视界面美观感兴趣的民众。当前,JavaFX某种E度上作为第四步产生的语a在运行,因ؓ首先是解释器?/span>FX脚本创徏成ؓJava代码Q然后再调用适当?/span>Java 2D API。该组长期的目标是?/span>FX脚本直接~译成字节码?/span>

  JavaFXd到桌?/span>Java是一仉常好的事情,但是Q这得取决于是否有这L一U?/span>JRE的存在,它能q行JavaFX生成的代码。有些h认ؓFX已经q军?/span>RIA(rich Internet application)领域Q和Adobe公司?/span> Flex一较高下。但是,目前q是有一些难题需要解冻I举个例子Q如何才能让桌面Java的安装体验和q行旉性能比得上其它的RIA框架。还好,q种问题正在被其他的目解决Q这个项目名U就?/span>Java kernel?/span>

  Java kerneld承认q么一个事情,卛_多数?/span>Java应用E序都是只有JRE的部分大,?/span>Limewire(一个文件共享的桌面应用E序)Q它只有JRE的三分之一大小?/span>Kernel会?/span>JRE重新打包Q得只下蝲应用E序所需要的部分JRE。每个程序所需要的基本部分会被下载,作ؓJRE启动所需要的最部分,其他的部分根据需要下载,或者根?/span>ClassNotFound异常信息Q下载缺qcR这是一个巨大的好消息帮助桌?/span>Java应用E序瘦nQ同时还能得桌?/span>Java应用E序执行的更为有效。除了解军_何下载的问题外,kernelq非常关?/span>JavaE序的启动性能?/span>

  在先前的kernel几个版本Q热启动旉(warm start times)减少了很多,但是Q在应用E序调用main(String[])前,冷启?/span>JRE仍然需要g误许多秒的时间?/span>Java kernel正在试有效的处理冷启动Q将冷启动{变ؓ热启动,通过一些相关的技术,如预加蝲(pre-loading)JREQ从盘d到内存,q有一个操作系l服务,q个服务的功能就是监视可分配的内存来加蝲JREQ得用戯得最佳的性能。出了这些,kernelq提供了一个新的浏览器插gQ提供给Web 开发者更多的关于桌面q行信息Q可获得?/span>JRE水^{等?/span>

  对于桌面Java来说Q?/span>Java kernel ?/span>Java FX两大好消息。说Kernel是一个非常好的技术,是因为它承认?/span>Swing已经C一个非常成熟的阶段Qƈ且帮助开发这如何他们的Java应用E序更ؓ快速,更ؓ有效的搬到用h面上。说FX是两外一个非常好的消息,是因为它?/span>Java开发者打开了新章Q特别是那些愿意使用脚本语言和做一些高U的Q活波的Q图形效果的开发者,他们只需要写单几行代码就可以完成。我怿q两Ҏ术将会得更多的应用E序?/span>Java语言~写Q运行在用户的机器上Q同Ӟ对于用户和开发者来_应用E序变得更快Q更单?/span>


RomKK 2007-07-26 09:49 发表评论
]]>
ZSwing的免费look and feel(有很多哟)http://www.aygfsteel.com/RomKK/archive/2007/07/25/132215.htmlRomKKRomKKWed, 25 Jul 2007 01:56:00 GMThttp://www.aygfsteel.com/RomKK/archive/2007/07/25/132215.htmlhttp://www.aygfsteel.com/RomKK/comments/132215.htmlhttp://www.aygfsteel.com/RomKK/archive/2007/07/25/132215.html#Feedback4http://www.aygfsteel.com/RomKK/comments/commentRss/132215.htmlhttp://www.aygfsteel.com/RomKK/services/trackbacks/132215.html
      用java写桌面程序的时候,L抱怨Swing的页面太隄Q而很多的Look and Feel 都是收费的?br>
      今天发现一个好东东Q全是免费的Q效果还不错呀Q感兴趣的话赶紧M吧!

     下蝲地址Q?http://www.javootoo.com/  上有一个free look and feel 栏目


RomKK 2007-07-25 09:56 发表评论
]]>
?K内存实现高效I/O的RandomAccessFilec?/title><link>http://www.aygfsteel.com/RomKK/archive/2007/07/25/132202.html</link><dc:creator>RomKK</dc:creator><author>RomKK</author><pubDate>Wed, 25 Jul 2007 01:32:00 GMT</pubDate><guid>http://www.aygfsteel.com/RomKK/archive/2007/07/25/132202.html</guid><wfw:comment>http://www.aygfsteel.com/RomKK/comments/132202.html</wfw:comment><comments>http://www.aygfsteel.com/RomKK/archive/2007/07/25/132202.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/RomKK/comments/commentRss/132202.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/RomKK/services/trackbacks/132202.html</trackback:ping><description><![CDATA[<p id=subtitle>通过扩展RandomAccessFilecM之具备Buffer改善I/O性能</p><br><script type="text/javascript"><!-- google_ad_client = "pub-4399204441904216"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text"; //2007-07-24: http://romkk.j5com.cn/blog google_ad_channel = "8013984535"; google_color_border = "F7F7F7"; google_color_bg = "F7F7F7"; google_color_link = "0000FF"; google_color_text = "000000"; google_color_url = "008000"; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script><br> <img class=display-img height=6 alt="" src="http://www.ibm.com/i/c.gif" width=1><br> <blockquote>JAVA的文仉机存取类QRandomAccessFileQ的I/O效率较低。通过分析其中原因Q提x案。逐步展示如何创徏具备~存d能力的文仉机存取类Qƈq行了优化。通过与其它文件访问类的性能ҎQ证明了其实用h倹{?/blockquote><!--start RESERVED FOR FUTURE USE INCLUDE FILES--><!-- include java script once we verify teams wants to use this and it will work on dbcs and cyrillic characters --><!--end RESERVED FOR FUTURE USE INCLUDE FILES--> <p><a name=N1003C><span id="wmqeeuq" class=smalltitle><strong><font face=Arial>MQ?/font></strong></span></a></p> <p>       开发h员用RandomAccessFilecL。其I/O性能较之其它常用开发语a的同cL能差距甚远Q严重媄响程序的q行效率。开发h员迫切需要提高效率,下面分析RandomAccessFile{文件类的源代码Q找出其中的症结所在,q加以改q优化,创徏一??h"׃的随机文件访问类BufferedRandomAccessFile?br></p> <p><a name=1><span id="wmqeeuq" class=atitle>在改q之前先做一个基本测试:逐字节COPY一?2兆的文gQ这里牵涉到d写)?/span></a></p> <p> <table width="60%" border=1> <tbody> <tr> <td>?/td> <td>?/td> <td>耗用旉Q秒Q?/td> </tr> <tr> <td>RandomAccessFile</td> <td>RandomAccessFile</td> <td>95.848</td> </tr> <tr> <td>BufferedInputStream + DataInputStream</td> <td>BufferedOutputStream + DataOutputStream</td> <td>2.935</td> </tr> </tbody> </table> <p>我们可以看到两者差距约32倍,RandomAccessFile也太慢了。先看看两者关键部分的源代码,Ҏ分析Q找出原因?/p> <p><strong>1Q?Q[RandomAccessFile]</strong> </p> <p> <table cellSpacing=0 cellPadding=0 width="100%" border=0> <tbody> <tr> <td class=code-outline> <pre class=displaycode>public class RandomAccessFile implements DataOutput, DataInput { public final byte readByte() throws IOException { int ch = this.read(); if (ch < 0) throw new EOFException(); return (byte)(ch); } public native int read() throws IOException; public final void writeByte(int v) throws IOException { write(v); } public native void write(int b) throws IOException; } </pre> </td> </tr> </tbody> </table> <br>可见QRandomAccessFile每读/写一个字节就需对磁盘进行一ơI/O操作?/p> <p><strong>1Q?Q[BufferedInputStream]</strong> </p> <p> <table cellSpacing=0 cellPadding=0 width="100%" border=0> <tbody> <tr> <td class=code-outline> <pre class=displaycode>public class BufferedInputStream extends FilterInputStream { private static int defaultBufferSize = 2048; protected byte buf[]; // 建立ȝ存区 public BufferedInputStream(InputStream in, int size) { super(in); if (size <= 0) { throw new IllegalArgumentException("Buffer size <= 0"); } buf = new byte[size]; } public synchronized int read() throws IOException { ensureOpen(); if (pos >= count) { fill(); if (pos >= count) return -1; } return buf[pos++] & 0xff; // 直接从BUF[]中读? } private void fill() throws IOException { if (markpos < 0) pos = 0; /* no mark: throw away the buffer */ else if (pos >= buf.length) /* no room left in buffer */ if (markpos > 0) { /* can throw away early part of the buffer */ int sz = pos - markpos; System.arraycopy(buf, markpos, buf, 0, sz); pos = sz; markpos = 0; } else if (buf.length >= marklimit) { markpos = -1; /* buffer got too big, invalidate mark */ pos = 0; /* drop buffer contents */ } else { /* grow buffer */ int nsz = pos * 2; if (nsz > marklimit) nsz = marklimit; byte nbuf[] = new byte[nsz]; System.arraycopy(buf, 0, nbuf, 0, pos); buf = nbuf; } count = pos; int n = in.read(buf, pos, buf.length - pos); if (n > 0) count = n + pos; } } </pre> </td> </tr> </tbody> </table> <br><strong>1Q?Q[BufferedOutputStream]</strong> </p> <p> <table cellSpacing=0 cellPadding=0 width="100%" border=0> <tbody> <tr> <td class=code-outline> <pre class=displaycode>public class BufferedOutputStream extends FilterOutputStream { protected byte buf[]; // 建立写缓存区 public BufferedOutputStream(OutputStream out, int size) { super(out); if (size <= 0) { throw new IllegalArgumentException("Buffer size <= 0"); } buf = new byte[size]; } public synchronized void write(int b) throws IOException { if (count >= buf.length) { flushBuffer(); } buf[count++] = (byte)b; // 直接从BUF[]中读? } private void flushBuffer() throws IOException { if (count > 0) { out.write(buf, 0, count); count = 0; } } } </pre> </td> </tr> </tbody> </table> </p> <p>可见QBuffered I/O putStream每读/写一个字节,若要操作的数据在BUF中,q接对内存的buf[]q行?写操作;否则从磁盘相应位|填充buf[]Q再直接对内存的buf[]q行?写操作,l大部分的读/写操作是对内存buf[]的操作?/p> <p><strong>1Q?Q小l?/strong> </p> <p>内存存取旉单位是纳UQ?0E-9Q,盘存取旉单位是毫UQ?0E-3Q,同样操作一ơ的开销Q内存比盘快了百万倍。理Z可以预见Q即使对内存操作上万ơ,p的时间也q少对于盘一ơI/O的开销。显然后者是通过增加位于内存的BUF存取Q减磁盘I/O的开销Q提高存取效率的Q当然这样也增加了BUF控制部分的开销。从实际应用来看Q存取效率提高了32倍?br></p> <p><a name=2><span id="wmqeeuq" class=atitle>Ҏ1.3得出的结论,现试着对RandomAccessFilecM加上~冲d机制?/span></a></p> <p> <p>随机讉KcM序cM同,前者是通过实现DataInput/DataOutput接口创徏的,而后者是扩展FilterInputStream/FilterOutputStream创徏的,不能直接照搬?/p> <p><strong>2Q?Q开辟缓冲区BUF[默认Q?024字节]Q用作读/写的q~冲区?/strong> </p> <p><strong>2Q?Q先实现ȝ册Ӏ?/strong> </p> <p>ȝ冲逻辑的基本原理:</p> <p>A Ʋ读文gPOS位置的一个字节?/p> <p>B 查BUF中是否存在?若有Q直接从BUF中读取,q返回该字符BYTE?/p> <p>C 若没有,则BUF重新定位到该POS所在的位置q把该位|附q的BUFSIZE的字节的文g内容填充BUFFERQ返回B?/p> <p>以下l出关键部分代码及其说明Q?/p> <p> <table cellSpacing=0 cellPadding=0 width="100%" border=0> <tbody> <tr> <td class=code-outline> <pre class=displaycode>public class BufferedRandomAccessFile extends RandomAccessFile { // byte read(long pos)Q读取当前文件POS位置所在的字节 // bufstartpos、bufendpos代表BUF映射在当前文件的?ցUd址? // curpos指当前类文g指针的偏Ud址? public byte read(long pos) throws IOException { if (pos < this.bufstartpos || pos > this.bufendpos ) { this.flushbuf(); this.seek(pos); if ((pos < this.bufstartpos) || (pos > this.bufendpos)) throw new IOException(); } this.curpos = pos; return this.buf[(int)(pos - this.bufstartpos)]; } // void flushbuf()Qbufdirty为真Q把buf[]中尚未写入磁盘的数据Q写入磁盘? private void flushbuf() throws IOException { if (this.bufdirty == true) { if (super.getFilePointer() != this.bufstartpos) { super.seek(this.bufstartpos); } super.write(this.buf, 0, this.bufusedsize); this.bufdirty = false; } } // void seek(long pos)Q移动文件指针到pos位置Qƈ把buf[]映射填充至POS 所在的文g块? public void seek(long pos) throws IOException { if ((pos < this.bufstartpos) || (pos > this.bufendpos)) { // seek pos not in buf this.flushbuf(); if ((pos >= 0) && (pos <= this.fileendpos) && (this.fileendpos != 0)) { // seek pos in file (file length > 0) this.bufstartpos = pos * bufbitlen / bufbitlen; this.bufusedsize = this.fillbuf(); } else if (((pos == 0) && (this.fileendpos == 0)) || (pos == this.fileendpos + 1)) { // seek pos is append pos this.bufstartpos = pos; this.bufusedsize = 0; } this.bufendpos = this.bufstartpos + this.bufsize - 1; } this.curpos = pos; } // int fillbuf()Q根据bufstartposQ填充buf[]? private int fillbuf() throws IOException { super.seek(this.bufstartpos); this.bufdirty = false; return super.read(this.buf); } } </pre> </td> </tr> </tbody> </table> </p> <p>x~冲d本实玎ͼ逐字节COPY一?2兆的文gQ这里牵涉到d写,用BufferedRandomAccessFile试一下读的速度Q:</p> <p> <table width="70%" border=1> <tbody> <tr> <td>?/td> <td>?/td> <td>耗用旉Q秒Q?/td> </tr> <tr> <td>RandomAccessFile</td> <td>RandomAccessFile</td> <td>95.848</td> </tr> <tr> <td>BufferedRandomAccessFile</td> <td>BufferedOutputStream + DataOutputStream</td> <td>2.813</td> </tr> <tr> <td>BufferedInputStream + DataInputStream</td> <td>BufferedOutputStream + DataOutputStream</td> <td>2.935</td> </tr> </tbody> </table> </p> <p>可见速度显著提高Q与BufferedInputStream+DataInputStream不相上下?/p> <p><strong>2Q?Q实现写~冲?/strong> </p> <p>写缓冲逻辑的基本原理:</p> <p>AƲ写文gPOS位置的一个字节?/p> <p>B 查BUF中是否有该映?若有Q直接向BUF中写入,q返回true?/p> <p>C若没有,则BUF重新定位到该POS所在的位置Qƈ把该位置附近?BUFSIZE字节的文件内容填充BUFFERQ返回B?/p> <p>下面l出关键部分代码及其说明Q?/p> <p> <table cellSpacing=0 cellPadding=0 width="100%" border=0> <tbody> <tr> <td class=code-outline> <pre class=displaycode>// boolean write(byte bw, long pos)Q向当前文gPOS位置写入字节BW? // ҎPOS的不同及BUF的位|:存在修改、追加、BUF中、BUF外等? c在逻辑判断Ӟ把最可能出现的情况,最先判断,q样可提高速度? // fileendposQ指C当前文件的ցUd址Q主要考虑到追加因? public boolean write(byte bw, long pos) throws IOException { if ((pos >= this.bufstartpos) && (pos <= this.bufendpos)) { // write pos in buf this.buf[(int)(pos - this.bufstartpos)] = bw; this.bufdirty = true; if (pos == this.fileendpos + 1) { // write pos is append pos this.fileendpos++; this.bufusedsize++; } } else { // write pos not in buf this.seek(pos); if ((pos >= 0) && (pos <= this.fileendpos) && (this.fileendpos != 0)) { // write pos is modify file this.buf[(int)(pos - this.bufstartpos)] = bw; } else if (((pos == 0) && (this.fileendpos == 0)) || (pos == this.fileendpos + 1)) { // write pos is append pos this.buf[0] = bw; this.fileendpos++; this.bufusedsize = 1; } else { throw new IndexOutOfBoundsException(); } this.bufdirty = true; } this.curpos = pos; return true; } </pre> </td> </tr> </tbody> </table> </p> <p>x~冲写基本实玎ͼ逐字节COPY一?2兆的文gQ(q里牉|到读和写Q结合缓冲读Q用BufferedRandomAccessFile试一下读/写的速度Q:</p> <p> <table width="60%" border=1> <tbody> <tr> <td>?/td> <td>?/td> <td>耗用旉Q秒Q?/td> </tr> <tr> <td>RandomAccessFile</td> <td>RandomAccessFile</td> <td>95.848</td> </tr> <tr> <td>BufferedInputStream + DataInputStream</td> <td>BufferedOutputStream + DataOutputStream</td> <td>2.935</td> </tr> <tr> <td>BufferedRandomAccessFile</td> <td>BufferedOutputStream + DataOutputStream</td> <td>2.813</td> </tr> <tr> <td>BufferedRandomAccessFile</td> <td>BufferedRandomAccessFile</td> <td>2.453</td> </tr> </tbody> </table> </p> <p>可见l合?写速度已超BufferedInput/OutputStream+DataInput/OutputStream?/p> <p><a name=3><span id="wmqeeuq" class=atitle>优化BufferedRandomAccessFile?/span></a></p> <p> <p>优化原则Q?/p> <ul> <li>调用频繁的语句最需要优化,且优化的效果最明显? <li>多重嵌套逻辑判断Ӟ最可能出现的判断,应放在最外层? <li>减少不必要的NEW?</li> </ul> <p>q里举一典型的例子:</p> <table cellSpacing=0 cellPadding=0 width="100%" border=0> <tbody> <tr> <td class=code-outline> <pre class=displaycode> public void seek(long pos) throws IOException { ... this.bufstartpos = pos * bufbitlen / bufbitlen; // bufbitlen指buf[]的位长,例:若bufsize=1024Q则bufbitlen=10? ... } </pre> </td> </tr> </tbody> </table> <p>seek函数使用在各函数中,调用非常频繁Q上面加重的q行语句Ҏpos和bufsize定buf[]对应当前文g的映位|,?*"?/"定Q显然不是一个好Ҏ?/p> <p>优化一Qthis.bufstartpos = (pos << bufbitlen) >> bufbitlen;</p> <p>优化二:this.bufstartpos = pos & bufmask; // this.bufmask = ~((long)this.bufsize - 1);</p> <p>两者效率都比原来好Q但后者显然更好,因ؓ前者需要两ơ移位运、后者只需一ơ逻辑与运(bufmask可以预先得出Q?/p> <p>x优化基本实现Q逐字节COPY一?2兆的文gQ(q里牉|到读和写Q结合缓冲读Q用优化后BufferedRandomAccessFile试一下读/写的速度Q:</p> <table width="60%" border=1> <tbody> <tr> <td>?/td> <td>?/td> <td>耗用旉Q秒Q?/td> </tr> <tr> <td>RandomAccessFile</td> <td>RandomAccessFile</td> <td>95.848</td> </tr> <tr> <td>BufferedInputStream + DataInputStream </td> <td>BufferedOutputStream + DataOutputStream</td> <td>2.935</td> </tr> <tr> <td>BufferedRandomAccessFile</td> <td>BufferedOutputStream + DataOutputStream</td> <td>2.813</td> </tr> <tr> <td>BufferedRandomAccessFile</td> <td>BufferedRandomAccessFile</td> <td>2.453</td> </tr> <tr> <td>BufferedRandomAccessFile?/td> <td>BufferedRandomAccessFile?/td> <td>2.197</td> </tr> </tbody> </table> <p>可见优化管不明显,q是比未优化前快了一些,也许q种效果在老式Z会更明显?/p> <p>以上比较的是序存取Q即使是随机存取Q在l大多数情况下也不止一个BYTEQ所以缓冲机制依然有效。而一般的序存取c要实现随机存取׃怎么Ҏ了?/p> <p><a name=4><span id="wmqeeuq" class=atitle>需要完善的地方</span></a></p> <p> <p>提供文gq加功能Q?/p> <table cellSpacing=0 cellPadding=0 width="100%" border=0> <tbody> <tr> <td class=code-outline> <pre class=displaycode> public boolean append(byte bw) throws IOException { return this.write(bw, this.fileendpos + 1); } </pre> </td> </tr> </tbody> </table> <p>提供文g当前位置修改功能Q?/p> <table cellSpacing=0 cellPadding=0 width="100%" border=0> <tbody> <tr> <td class=code-outline> <pre class=displaycode> public boolean write(byte bw) throws IOException { return this.write(bw, this.curpos); } </pre> </td> </tr> </tbody> </table> <p>q回文g长度Q由于BUFd的原因,与原来的RandomAccessFilecL所不同Q:</p> <table cellSpacing=0 cellPadding=0 width="100%" border=0> <tbody> <tr> <td class=code-outline> <pre class=displaycode> public long length() throws IOException { return this.max(this.fileendpos + 1, this.initfilelen); } </pre> </td> </tr> </tbody> </table> <p>q回文g当前指针Q由于是通过BUFd的原因,与原来的RandomAccessFilecL所不同Q:</p> <table cellSpacing=0 cellPadding=0 width="100%" border=0> <tbody> <tr> <td class=code-outline> <pre class=displaycode> public long getFilePointer() throws IOException { return this.curpos; } </pre> </td> </tr> </tbody> </table> <p>提供对当前位|的多个字节的缓冲写功能Q?/p> <table cellSpacing=0 cellPadding=0 width="100%" border=0> <tbody> <tr> <td class=code-outline> <pre class=displaycode> public void write(byte b[], int off, int len) throws IOException { long writeendpos = this.curpos + len - 1; if (writeendpos <= this.bufendpos) { // b[] in cur buf System.arraycopy(b, off, this.buf, (int)(this.curpos - this.bufstartpos), len); this.bufdirty = true; this.bufusedsize = (int)(writeendpos - this.bufstartpos + 1); } else { // b[] not in cur buf super.seek(this.curpos); super.write(b, off, len); } if (writeendpos > this.fileendpos) this.fileendpos = writeendpos; this.seek(writeendpos+1); } public void write(byte b[]) throws IOException { this.write(b, 0, b.length); } </pre> </td> </tr> </tbody> </table> <p>提供对当前位|的多个字节的缓冲读功能Q?/p> <table cellSpacing=0 cellPadding=0 width="100%" border=0> <tbody> <tr> <td class=code-outline> <pre class=displaycode>public int read(byte b[], int off, int len) throws IOException { long readendpos = this.curpos + len - 1; if (readendpos <= this.bufendpos && readendpos <= this.fileendpos ) { // read in buf System.arraycopy(this.buf, (int)(this.curpos - this.bufstartpos), b, off, len); } else { // read b[] size > buf[] if (readendpos > this.fileendpos) { // read b[] part in file len = (int)(this.length() - this.curpos + 1); } super.seek(this.curpos); len = super.read(b, off, len); readendpos = this.curpos + len - 1; } this.seek(readendpos + 1); return len; } public int read(byte b[]) throws IOException { return this.read(b, 0, b.length); } public void setLength(long newLength) throws IOException { if (newLength > 0) { this.fileendpos = newLength - 1; } else { this.fileendpos = 0; } super.setLength(newLength); } public void close() throws IOException { this.flushbuf(); super.close(); } </pre> </td> </tr> </tbody> </table> <p>x完善工作基本完成Q试一下新增的多字节读/写功能,通过同时??024个字节,来COPY一?2兆的文gQ(q里牉|到读和写Q用完善后BufferedRandomAccessFile试一下读/写的速度Q:</p> <table width="70%" border=1> <tbody> <tr> <td>?/td> <td>?/td> <td>耗用旉Q秒Q?/td> </tr> <tr> <td>RandomAccessFile</td> <td>RandomAccessFile</td> <td>95.848</td> </tr> <tr> <td>BufferedInputStream + DataInputStream</td> <td>BufferedOutputStream + DataOutputStream</td> <td>2.935</td> </tr> <tr> <td>BufferedRandomAccessFile</td> <td>BufferedOutputStream + DataOutputStream</td> <td>2.813</td> </tr> <tr> <td>BufferedRandomAccessFile</td> <td>BufferedRandomAccessFile</td> <td>2.453</td> </tr> <tr> <td>BufferedRandomAccessFile?/td> <td>BufferedRandomAccessFile?/td> <td>2.197</td> </tr> <tr> <td>BufferedRandomAccessFile?/td> <td>BufferedRandomAccessFile?/td> <td>0.401</td> </tr> </tbody> </table> <p><a name=5><span id="wmqeeuq" class=atitle>与JDK1.4cMappedByteBuffer+RandomAccessFile的对比?</span></a></p> <p> <p>JDK1.4提供了NIOc?Q其中MappedByteBuffercȝ于映缓Ԍ也可以映随机文件访问,可见JAVA设计者也看到了RandomAccessFile的问题,q加以改q。怎么通过MappedByteBuffer+RandomAccessFile拯文g呢?下面是试E序的主要部分:</p> <table cellSpacing=0 cellPadding=0 width="100%" border=0> <tbody> <tr> <td class=code-outline> <pre class=displaycode>RandomAccessFile rafi = new RandomAccessFile(SrcFile, "r"); RandomAccessFile rafo = new RandomAccessFile(DesFile, "rw"); FileChannel fci = rafi.getChannel(); FileChannel fco = rafo.getChannel(); long size = fci.size(); MappedByteBuffer mbbi = fci.map(FileChannel.MapMode.READ_ONLY, 0, size); MappedByteBuffer mbbo = fco.map(FileChannel.MapMode.READ_WRITE, 0, size); long start = System.currentTimeMillis(); for (int i = 0; i < size; i++) { byte b = mbbi.get(i); mbbo.put(i, b); } fcin.close(); fcout.close(); rafi.close(); rafo.close(); System.out.println("Spend: "+(double)(System.currentTimeMillis()-start) / 1000 + "s"); </pre> </td> </tr> </tbody> </table> <p>试一下JDK1.4的映缓冲读/写功能,逐字节COPY一?2兆的文gQ(q里牉|到读和写Q:</p> <table width="60%" border=1> <tbody> <tr> <td>?/td> <td>?/td> <td>耗用旉Q秒Q?/td> </tr> <tr> <td>RandomAccessFile</td> <td>RandomAccessFile</td> <td>95.848</td> </tr> <tr> <td>BufferedInputStream + DataInputStream</td> <td>BufferedOutputStream + DataOutputStream</td> <td>2.935</td> </tr> <tr> <td>BufferedRandomAccessFile</td> <td>BufferedOutputStream + DataOutputStream</td> <td>2.813</td> </tr> <tr> <td>BufferedRandomAccessFile</td> <td>BufferedRandomAccessFile</td> <td>2.453</td> </tr> <tr> <td>BufferedRandomAccessFile?/td> <td>BufferedRandomAccessFile?/td> <td>2.197</td> </tr> <tr> <td>BufferedRandomAccessFile?/td> <td>BufferedRandomAccessFile?/td> <td>0.401</td> </tr> <tr> <td>MappedByteBuffer+ RandomAccessFile</td> <td>MappedByteBuffer+ RandomAccessFile</td> <td>1.209</td> </tr> </tbody> </table> <p>实不错Q如果以后采?.4版本开发Y件时Q需要对文gq行随机讉KQ徏议采用MappedByteBuffer+RandomAccessFile的方式。但鉴于目前采用JDK1.3及以前的版本开发的E序占绝大多数的实际情况Q如果您开发的JAVAE序使用了RandomAccessFilecL随机讉K文gQƈ因其性能不佳Q而担心遭用户诟病Q请试用本文所提供的BufferedRandomAccessFilec,不必推翻重写Q只需IMPORT 本类Q把所有的RandomAccessFile改ؓBufferedRandomAccessFileQ您的程序的性能得到极大的提升Q您所要做的就q么单?/p> <p><a name=6><span id="wmqeeuq" class=atitle>未来的考虑</span></a></p> <p> <p>读者可在此基础上徏立多늼存及~存淘汰机制Q以应付寚w问强度大的应用?/p> Q完整代码见下篇Q? <br> <script type="text/javascript"><!-- google_ad_client = "pub-4399204441904216"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "image"; //2007-07-24: http://romkk.j5com.cn/blog google_ad_channel = "8013984535"; google_color_border = "F7F7F7"; google_color_bg = "F7F7F7"; google_color_link = "0000FF"; google_color_text = "000000"; google_color_url = "008000"; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> <img src ="http://www.aygfsteel.com/RomKK/aggbug/132202.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/RomKK/" target="_blank">RomKK</a> 2007-07-25 09:32 <a href="http://www.aygfsteel.com/RomKK/archive/2007/07/25/132202.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>一个程序员的成长的六个阶段http://www.aygfsteel.com/RomKK/archive/2007/07/24/132155.htmlRomKKRomKKTue, 24 Jul 2007 14:22:00 GMThttp://www.aygfsteel.com/RomKK/archive/2007/07/24/132155.htmlhttp://www.aygfsteel.com/RomKK/comments/132155.htmlhttp://www.aygfsteel.com/RomKK/archive/2007/07/24/132155.html#Feedback0http://www.aygfsteel.com/RomKK/comments/commentRss/132155.htmlhttp://www.aygfsteel.com/RomKK/services/trackbacks/132155.html
W一阶段
此阶D主要是能熟l地使用某种语言。这q当于l武中的套\和架式这些表面的东西?br>W二阶段
此阶D能_N基于某U^台的接口Q例如我们现在常用的Win 32的API函数Q以及所对应语言的自w的库函数。到达这个阶D后Q也q当于可以q行真实散打对练了,可以真正地在实践中做些应用?br>W三阶段
此阶D能深入C解某个^台系l的底层Q已l具有了初的内功的能力Q也是“手中有剑Q心中无?#8221;?br>W四阶
此阶D能直接在^Cq行比较深层ơ的开发。基本上Q能辑ֈq个层次可以说是进入了高层ơ。这时进入了高内功的修点{比如能q行VxD或操作系l的内核的修攏V?br>q时已经不再有语a的束~,语言只是一U工P即要用自己不会的语aq行开发,也只是简单地熟悉一下,手到擒来,完全不像是第一阶段的时候学习语a的那U情c一般来_从第三阶D过渡到W四阶段是比较困隄。ؓ什么会隑֑Q这是因ؓ很多人的思想变不q来?br>W五阶
此阶D就已经不再局限于单的技术上的问题了Q而是能从全局上把握和设计一个比较大的系l体pȝ构,从内核到外层界面。可以说?#8220;手中无剑Q心中有?#8221;。到了这个阶D以后,能对市面上的M软gq行剖析Qƈ能按自己的要求进行设计,q是MS Wordq样的大型YӞ只要有充的旉Q也一定会设计出来?br>W六阶
此阶D也是最高的境界Q达?#8220;无招胜有?#8221;。这时候,M问题q_变成了一个思\的问题,不是用什么代码就能表C的。也是“手中无剑Q心中也无剑”?br>此时Q对于练功的人来_他已不用再去学什么少林拳Q只是在旁看一下少林拳的对战,p把此x来就用。这是真正的大师的h物。这ӞWin 32或Linux在你眼里是没有什么差别的?br>每一个阶D再向上发展旉要按一定的Ҏ。第一、第二个阶段通过自学可以完成,只要多用心去研究Q耐心地去学习?br>要想从第二个阶段q渡到第三个阶段Q就要有一个好的学习环境。例如有一个高手带领或公司里有一个好的练手环境。经q二、三q的U篏p辑ֈW三个阶Dc但是,有些人到辄三个阶段后,常常很难有境界上的H破了。他们这时会产生一U观念,认ؓ软g无非如此Q认己已无所不能。其实,q时如果遇到大的或难些的软gQ他们往往q是无从下手?br>现在我们国家大部分程序员都是在第二、三U之间。他们大多都是通过自学成才的,不过q样的程序员一般在软g公司也能独当一面,完成一些Y件的模块?br>但是Q也q有一大堆处在W一阶段的程序员Q他们一般就能玩玩VBQ做E序ӞL一堆控仉成一个Y?



RomKK 2007-07-24 22:22 发表评论
]]>
微Y好员工的十个标准http://www.aygfsteel.com/RomKK/archive/2007/07/24/132154.htmlRomKKRomKKTue, 24 Jul 2007 14:21:00 GMThttp://www.aygfsteel.com/RomKK/archive/2007/07/24/132154.htmlhttp://www.aygfsteel.com/RomKK/comments/132154.htmlhttp://www.aygfsteel.com/RomKK/archive/2007/07/24/132154.html#Feedback0http://www.aygfsteel.com/RomKK/comments/commentRss/132154.htmlhttp://www.aygfsteel.com/RomKK/services/trackbacks/132154.html
1、对自己所在公司或部门的品具有v码的好奇心是极ؓ重要的一炏V你必须亲自使用该品。对于n处计机行业的h来说,q一Ҏ么都不。当Ӟq一点同样适用于其他知识密集型领域Q因为在q些领域内技术与应用发展更新极快Q对其技术的掌握很难做到一x逸。如果你对这些品没什么兴,你将很快落伍Qƈ被淘汰出局?br> 
2、在与客户交谈如何用品时Q需要以极大的兴和传道士般的热情和执着打动客户Q了解他们欣赏什么,不喜Ƣ什么。同时必L醒地知道本公司的产品有哪些不I或哪里可以改q?br>  
3、了解了客户的需求后Q必M于思考如何让产品更脓qƈ帮助客户?br> 
4、作Z个独立的员工Q必M公司制定的长期计划保持步调一致。员工需要关注其ln的努力方向,如提高自w及同事的能力?br>  
5、在对于周遭事物h高度z察力的同时Q必L握某U专业知识和技能。特别是一些大公司Q他们要求员工迅速掌握专业技术。没有h能保证他目前拥有的技能仍适用于将来的工作Q所以,好学_是非常关键的?br>  
6、非常灵zd利用那些有利于发展的Z。在微YQ我们通过一pdҎ为每一个h提供许多不同的工作机会。Q何热衷参与微软管理的员工Q都被鼓励在不同客h务部门工作?br>  
7、一个好的员工会量d习了解公怸务运作的l济原理Qؓ什么公司的业务会这栯作?公司的业务模式是什么?如何才能盈利Q员工必M解导致本行业中企业盈利或亏损的原因,才能对自己所从事的工作的价值有更深入的理解?br>  
8、关注竞争对手的动态。我非常ƣ赏那些随时注意整个市场动态的员工Q他们会分析我们的竞争对手的可借鉴之处Qƈ注意ȝQ避免重q竞争对手的错误?br>  
9、好的员工善于动脑子。分析问题,但ƈ不局限于分析。他们知道如何寻找潜在的q点,如何L最佳的行动时机。思考还要与实践相结合。好的员工会合理、高效地利用旉Qƈ会ؓ其他部门清楚地提出徏议?br> 
10、不要忽略了一些必d备的dQ如诚实、有道d和刻苦,q些都是很重要的Q在此无需赘言?/strong>


RomKK 2007-07-24 22:21 发表评论
]]>
myeclipse5.5GA版的注册?/title><link>http://www.aygfsteel.com/RomKK/archive/2007/07/24/131972.html</link><dc:creator>RomKK</dc:creator><author>RomKK</author><pubDate>Tue, 24 Jul 2007 01:54:00 GMT</pubDate><guid>http://www.aygfsteel.com/RomKK/archive/2007/07/24/131972.html</guid><wfw:comment>http://www.aygfsteel.com/RomKK/comments/131972.html</wfw:comment><comments>http://www.aygfsteel.com/RomKK/archive/2007/07/24/131972.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.aygfsteel.com/RomKK/comments/commentRss/131972.html</wfw:commentRss><trackback:ping>http://www.aygfsteel.com/RomKK/services/trackbacks/131972.html</trackback:ping><description><![CDATA[<script type="text/javascript"><!-- google_ad_client = "pub-4399204441904216"; google_ad_width = 728; google_ad_height = 15; google_ad_format = "728x15_0ads_al_s"; //2007-07-24: http://romkk.j5com.cn/blog google_ad_channel = "8013984535"; //--> </script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script><p><br>新免覆盖注册<br>更新说明Q不使用覆盖安装法,直接输入注册码即可?br><br>下面?5.5 GA 版本?#8220;注册信息”“注册?#8221;“破解”l大Ӟ<br>Subscriber: <a target=_blank><font face=Tahoma color=#2f5fa1>www.1cn.biz</font></a><br>Subscriber Code: jLR7ZL-655355-5450755330522962<br><br>旉:20090520</p> <!-- Begin #sidebar --> <div class="wmqeeuq" id=sidebar> <div class="wmqeeuq" id=sidebar2><script type="text/javascript"><!-- google_ad_client = "pub-4399204441904216"; google_ad_width = 728; google_ad_height = 90; google_ad_format = "728x90_as"; google_ad_type = "text"; //2007-07-23: http://romkk.j5com.cn/blog google_ad_channel = "8013984535"; //--> </script><script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script></div> </div> <img src ="http://www.aygfsteel.com/RomKK/aggbug/131972.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.aygfsteel.com/RomKK/" target="_blank">RomKK</a> 2007-07-24 09:54 <a href="http://www.aygfsteel.com/RomKK/archive/2007/07/24/131972.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss> <footer> <div class="friendship-link"> <a href="http://www.aygfsteel.com/" title="狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频">狠狠久久亚洲欧美专区_中文字幕亚洲综合久久202_国产精品亚洲第五区在线_日本免费网站视频</a> </div> </footer> վ֩ģ壺 <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ɽ</a>| <a href="http://" target="_blank">¡</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">Դ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ѳ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ˮ</a>| <a href="http://" target="_blank">Ѩ</a>| <a href="http://" target="_blank">ɣֲ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ij</a>| <a href="http://" target="_blank">̨</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ն</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ϴ</a>| <a href="http://" target="_blank">״</a>| <a href="http://" target="_blank">ű</a>| <a href="http://" target="_blank">Ϫ</a>| <a href="http://" target="_blank">Ϫ</a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank"></a>| <a href="http://" target="_blank">ͷ</a>| <a href="http://" target="_blank"></a>| <script> (function(){ var bp = document.createElement('script'); var curProtocol = window.location.protocol.split(':')[0]; if (curProtocol === 'https') { bp.src = 'https://zz.bdstatic.com/linksubmit/push.js'; } else { bp.src = 'http://push.zhanzhang.baidu.com/push.js'; } var s = document.getElementsByTagName("script")[0]; s.parentNode.insertBefore(bp, s); })(); </script> </body>