Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!news.stack.nl!aioe.org!.POSTED!not-for-mail From: Roedy Green Newsgroups: comp.lang.java.programmer Subject: NIO not so hot Date: Sat, 17 May 2014 04:28:19 -0700 Organization: Canadian Mind Products Lines: 19 Message-ID: Reply-To: Roedy Green NNTP-Posting-Host: K2Qzzs3EAqXk5RLzfhxcSw.user.speranza.aioe.org Mime-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Complaints-To: abuse@aioe.org User-Agent: ForteAgent/7.20.32.1218 X-Notice: Filtered by postfilter v. 0.8.2 Xref: csiph.com comp.lang.java.programmer:28517 I did a benchmark to read a file of bytes in one I/O then convert it to a String // Using a random sample data file of 419,430,400 chars 419,430,400 bytes UTF-8. // RandomAccess 1.46 seconds // InputStream 1.48 seconds // NIO 1.56 seconds NIO is great for grabbing bytes, but if you have to suck them out of the buffer, it does a get() call on every byte. The code is posted at http://mindprod.com/jgloss/nio.html -- Roedy Green Canadian Mind Products http://mindprod.com Young man, in mathematics you don’t understand things. You just get used to them. ~ John von Neumann (born: 1903-12-28 died: 1957-02-08 at age: 53)