Transfer a byte[] via TCP Socket in android
<p>I need to transfer a byte[] via TCP Socket in android -client side.<br>
i tried to use the following code :</p>

<pre><code>public static int readBytes(byte[] myByteArray) throws IOException {
    InputStream in = socket.getInputStream();
    DataInputStream dis = new DataInputStream(in);

    int len = dis.readInt(); //&lt;-here i get the error

    byte[] data = new byte[len];
    if (len &gt; 0) {
        dis.readFully(data,0,len);
    }
    myByteArray=data;
    return data.length;
}
</code></pre>

<p>but I get the following error:</p>

<blockquote>
  <p>12-23 17:30:49.814: E/AndroidRuntime(11717):
  java.lang.OutOfMemoryError: array size too large(Heap Size=5699KB,
  Allocated=3403KB, Bitmap Size=78KB)</p>
</blockquote>
