Path: csiph.com!x330-a1.tempe.blueboxinc.net!usenet.pasdenom.info!aioe.org!eternal-september.org!feeder.eternal-september.org!.POSTED!not-for-mail From: Eric Sosman Newsgroups: comp.lang.java.programmer Subject: Re: DataInputStream Date: Wed, 05 Oct 2011 21:16:18 -0400 Organization: A noiseless patient Spider Lines: 31 Message-ID: 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> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit Injection-Date: Thu, 6 Oct 2011 01:17:34 +0000 (UTC) Injection-Info: mx04.eternal-september.org; posting-host="f8igmItKsWs6nM5YanFxAA"; logging-data="3055"; mail-complaints-to="abuse@eternal-september.org"; posting-account="U2FsdGVkX180UoiWiGx4elJcjt8HkL94" User-Agent: Mozilla/5.0 (Windows NT 5.1; rv:7.0.1) Gecko/20110929 Thunderbird/7.0.1 In-Reply-To: <02b9b80f-ff02-499d-8f33-056080b114bb@s9g2000yql.googlegroups.com> Cancel-Lock: sha1:4I3bYtjzXE204t0iY+7/2v5nr/Y= Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8587 On 10/5/2011 10:17 AM, bob wrote: > The issue is that it's too slow. > > What I'm hoping for is something like this: > > byte[] b = new byte[numfloats*4]; > dis.read(b, 0, numfloats*4); > float[] f = (float[]) b; > return f; > > I don't know why, but it won't let me do the cast. Any ideas? "Why" is because an array of byte is not an array of float. Objects in Java (an array is an object) are not just blobs of memory; they have more identity, more selfhood. The wider problem you seem to be struggling with is that reading these numbers is "slow as molasses" (as you so precisely put it in a related thread). Several people have suggested that you (a) refine your notions of slowness and (b) take various steps to determine what contributes to it. As far as I can see you've done neither: You're simply assuming (on no basis that's been revealed) that the process of assembling bytes into floats is the fount of treacle. That's conceivable, just, but strikes me as highly unlikely. Go, and sin no more: Make some measurements of where the time goes, and attack the measured hot spots instead of your imagined phantoms. -- Eric Sosman esosman@ieee-dot-org.invalid