Path: csiph.com!x330-a1.tempe.blueboxinc.net!newsfeed.hal-mli.net!feeder3.hal-mli.net!nx02.iad01.newshosting.com!newshosting.com!69.16.185.11.MISMATCH!npeer01.iad.highwinds-media.com!news.highwinds-media.com!feed-me.highwinds-media.com!postnews.google.com!glegroupsg2000goo.googlegroups.com!not-for-mail From: Lew Newsgroups: comp.lang.java.programmer Subject: Re: optional operation Date: Thu, 6 Oct 2011 06:47:37 -0700 (PDT) Organization: http://groups.google.com Lines: 39 Message-ID: <10179923.1102.1317908858001.JavaMail.geo-discussion-forums@prcs9> References: <5eb0fcba-199f-46e4-b913-2f3e851d89fc@q26g2000vby.googlegroups.com> <6745899f-3c13-4d2b-81fb-52975c560a3b@q24g2000vby.googlegroups.com> Reply-To: comp.lang.java.programmer@googlegroups.com NNTP-Posting-Host: 173.164.137.214 Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 X-Trace: posting.google.com 1317908858 31114 127.0.0.1 (6 Oct 2011 13:47:38 GMT) X-Complaints-To: groups-abuse@google.com NNTP-Posting-Date: Thu, 6 Oct 2011 13:47:38 +0000 (UTC) In-Reply-To: Complaints-To: groups-abuse@google.com Injection-Info: glegroupsg2000goo.googlegroups.com; posting-host=173.164.137.214; posting-account=CP-lKQoAAAAGtB5diOuGlDQk0jIwmH0T User-Agent: G2/1.0 X-Google-Web-Client: true Xref: x330-a1.tempe.blueboxinc.net comp.lang.java.programmer:8594 On Wednesday, October 5, 2011 11:46:11 PM UTC-7, bob wrote: PLEASE do not top-post! PLEASE stop embedding TAB characters in your listings! Dude. Really. > Here's what I tried: > > AssetManager am = this.getResources().getAssets(); > > AssetFileDescriptor afd = am.openFd(filename); > FileInputStream fis = afd.createInputStream(); > FileChannel fchan = fis.getChannel(); > ByteBuffer inBuff = ByteBuffer.allocateDirect( 24121*4 ); > int bytesread = fchan.read( inBuff ); > > FloatBuffer floatBuffer = inBuff.asFloatBuffer(); > > float[] floats = new float[ 24121 ]; > floatBuffer.get( floats); > return floats; > > However, I always get a BufferUnderflowException at > floatBuffer.get( floats); > > 10-05 23:37:07.400: ERROR/AndroidRuntime(3570): Caused by: > java.nio.BufferUnderflowException > > For some reason, floatBuffer thinks it has a capacity of 0 after it's > created. > > Any ideas? buffer 'flip()'? -- Lew