Hi Haravikk, Thanks for the suggestion and on fist glance it looks like this ought to work, but no such luck :-(
The InputStreamReader has two things going against it for large array operations. 1. It allocates a huge buffer (way larger than the 8K advertised). Whenever it tried it to read 200,000 chars the LogCat shows "... dvmMalloc(24960292/0x017cdd24): someone's allocating a huge buffer" It is trying to allocate a 24mB buffer ??? 2. It wants to process the byte[] array character by character byte by byte with a CharsetDecoder object which makes it a painfully slow operation. I'm gona keep plugging away at the JNI/NDK option. Thank you! On Sep 2, 9:02 am, Haravikk <[email protected]> wrote: > Can't you just use an InputStreamReader wrapping around your > InputStream? Like so: > > char[] cBuffer = new char[1000000]; > InputStreamReader reader = new InputStreamReader(dInStream); > numBytesRead = reader.read(cBuffer); > > The problem with ByteBuffers is that they are only meant to hold data > temporarily, and it sounds like you'd be reading a large byte array > in, then converting to a large char-array which isn't pretty. > > On Sep 2, 12:18 pm,WoodManEXP<[email protected]> wrote: > > > > > Hi Dmitry, > > > Thank you for responding. The chars I’d like to read are two byte > > chars (they really are an array of ushorts, but the java char type > > represents them OK). > > > As far as I can tell there is simply no way in Java to implement a > > seemingly obvious sequence of statements like: > > > char[] cBuffer = new char[1000000]; > > numBytesRead = dInStream.read(cBuffer); > > > The java.io classes will read only byte[] arrays or will read only one > > char element at the time (painfully slow). The facilities for > > converting the byte[] array to any other data types (java.nio stuff) > > are painfully slow as well. > > > One suggestion has been to use JNI (NDK in Android lingo). Jeeze, what > > a convoluted mess that is… But I’m going to look into it to write a > > native function to do the read or maybe cast a short[] to a byte[] to > > fool the java.io read method. > > > If anyone can share any ideas that will be great. > > > Thanks!- Hide quoted text - > > - Show quoted text - --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [email protected] For more options, visit this group at http://groups.google.com/group/android-developers?hl=en -~----------~----~----~----~------~----~------~--~---

