Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.java.programmer > #8592
| From | bob <bob@coolgroups.com> |
|---|---|
| Newsgroups | comp.lang.java.programmer |
| Subject | Re: optional operation |
| Date | 2011-10-05 23:46 -0700 |
| Organization | http://groups.google.com |
| Message-ID | <a1d9260d-6f6f-456c-a49c-ae8a0bfd2c9a@5g2000yqo.googlegroups.com> (permalink) |
| References | <5eb0fcba-199f-46e4-b913-2f3e851d89fc@q26g2000vby.googlegroups.com> <c_idnaoeDvisCRHTnZ2dnUVZ_rWdnZ2d@earthlink.com> <6745899f-3c13-4d2b-81fb-52975c560a3b@q24g2000vby.googlegroups.com> <j6in1n$fil$1@dont-email.me> <j6inr7$jms$1@dont-email.me> |
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? On Oct 5, 6:05 pm, markspace <-@.> wrote: > On 10/5/2011 3:51 PM, markspace wrote: > > > On 10/5/2011 2:20 PM, bob wrote: > >> Thanks, but I am still confused. How can a buffer not be backed by an > >> accessible array? > > > I would have guessed due to this method here: > > > <http://download.oracle.com/javase/6/docs/api/java/nio/ByteBuffer.html...> > > > You'll need to read the comments at the begging of that page to > > understand what it is doing. > > Should be "beginning" not begging. Typing fast, didn't proofread. > > Meant to add too that you seemed to have discovered another reason that > the array would not be accessible --- the Buffer wraps another buffer, > which is fine.
Back to comp.lang.java.programmer | Previous | Next — Previous in thread | Next in thread | Find similar
optional operation bob <bob@coolgroups.com> - 2011-10-05 09:49 -0700
Re: optional operation Patricia Shanahan <pats@acm.org> - 2011-10-05 10:30 -0700
Re: optional operation bob <bob@coolgroups.com> - 2011-10-05 14:20 -0700
Re: optional operation markspace <-@.> - 2011-10-05 15:51 -0700
Re: optional operation markspace <-@.> - 2011-10-05 16:05 -0700
Re: optional operation bob <bob@coolgroups.com> - 2011-10-05 23:46 -0700
Re: optional operation Lew <lewbloch@gmail.com> - 2011-10-06 06:47 -0700
csiph-web