【发布时间】:2012-01-04 19:49:09
【问题描述】:
我需要通过 android -client 端的 TCP Socket 传输一个字节[]。
我尝试使用以下代码:
public static int readBytes(byte[] myByteArray) throws IOException {
InputStream in = socket.getInputStream();
DataInputStream dis = new DataInputStream(in);
int len = dis.readInt(); //<-here i get the error
byte[] data = new byte[len];
if (len > 0) {
dis.readFully(data,0,len);
}
myByteArray=data;
return data.length;
}
但我收到以下错误:
12-23 17:30:49.814: E/AndroidRuntime(11717): java.lang.OutOfMemoryError:数组大小太大(堆大小=5699KB, 已分配=3403KB,位图大小=78KB)
【问题讨论】: