Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!news.lightlink.com!news.iecc.com!border3.nntp.dca.giganews.com!Xl.tags.giganews.com!border1.nntp.dca.giganews.com!nntp.giganews.com!local2.nntp.dca.giganews.com!nntp.earthlink.com!news.earthlink.com.POSTED!not-for-mail NNTP-Posting-Date: Wed, 05 Oct 2011 17:15:43 -0500 Date: Wed, 05 Oct 2011 15:15:44 -0700 From: Patricia Shanahan User-Agent: Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US; rv:1.9.2.22) Gecko/20110902 Thunderbird/3.1.14 MIME-Version: 1.0 Newsgroups: comp.lang.java.programmer Subject: Re: DataInputStream References: <1418dd7f-d5d1-4a2c-b77b-87666f6a9591@k15g2000yqd.googlegroups.com> <9f2a8cFh1nU1@mid.individual.net> <6cf66421-77a9-4088-b810-3bcc958cc8ca@i28g2000yqn.googlegroups.com> <2ec7550a-a3d9-40a9-bca1-e1fd2586429d@g33g2000yqc.googlegroups.com> <02b9b80f-ff02-499d-8f33-056080b114bb@s9g2000yql.googlegroups.com> <64b13101-4846-42d7-bc75-458eb326f73f@n8g2000yqd.googlegroups.com> <20878450.465.1317851548409.JavaMail.geo-discussion-forums@prcs9> In-Reply-To: <20878450.465.1317851548409.JavaMail.geo-discussion-forums@prcs9> Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Message-ID: Lines: 24 X-Usenet-Provider: http://www.giganews.com NNTP-Posting-Host: 70.230.200.54 X-Trace: sv3-Saa2pqz7dvfuICG2U6JIDTAeALLxSHSJU6GH2sOLcyfsupg4fcaoEQfSfpzVE4/mLs6FjEAGCZzs8Gj!9+fNXshiuxaCpQDbeEjo2npIGrxIFqSVDteO2Jx/8Br3mPyRjen51lpspww0X87UdO7M1imcP8NQ!Fv+TTHnBB1dqYJSB8qYUjr7wne+g39DMWq1NIODLY+1guw== X-Abuse-and-DMCA-Info: Please be sure to forward a copy of ALL headers X-Abuse-and-DMCA-Info: Otherwise we will be unable to process your complaint properly X-Postfilter: 1.3.40 X-Original-Bytes: 2465 Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8582 On 10/5/2011 2:52 PM, Lew wrote: ... > As another respondent suggested, NIO lets you alias typed > 'ByteBuffer' instances as other types of 'Buffer'. > > But this defeats the purpose of 'DataInputStream', which handles > those mechanics for you under the hood, so why in the world reinvent > the wheel? Just read your array of floats from the DIS. I don't know whether this is one of those cases, but there are situations in which the main limitation on data read speed is data copying. There are two things that can reduce copy cost: 1. Do as few copies as possible. 2. When a copy is necessary, do it in bulk rather than element-by-element. I think the NIO buffer aliasing may be a way of eliminating some element-by-element copying. Sometimes, in trade-offs between performance and code simplicity, performance has to win. Patricia