Hi, Read more than 1 byte at a time, use an array buffer.
Regards On Jun 25, 6:06 pm, Azmat Alikhan <alikhan.az...@gmail.com> wrote: > I'm using sockets for data transfer from one android phone and PC, it is > taking 15 seconds to read about 1 Mb of data. I want to improve its > performance. > > Could anyone suggest any better way to do that? > > My Code is: > > InputStream is= socket.getInputStream(); > DataInputStream inChannel= new DataInputStream(new BufferedInputStream(in)); > ByteArrayOutputStream baos = new ByteArrayOutputStream(); > int oneByte; > while ((oneByte = inChannel.read()) != -1) { > if (oneByte == 0) { > break; > } > baos.write(oneByte); > byteCount++; > } > byte[] inData = baos.toByteArray(); > baos.close(); -- You received this message because you are subscribed to the Google Groups "Android Developers" group. To post to this group, send email to android-developers@googlegroups.com To unsubscribe from this group, send email to android-developers+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/android-developers?hl=en