我正在使用 asyncTask 通过套接字将图像从 Android 发送到 PC。
我这样称呼它
new SendImage().execute(data);
其中数据是类型byte[]
我的代码是
private class SendImage extends AsyncTask<byte[],Void, Void> {
@Override
protected Void doInBackground(byte[] ... data) {
try{
final DataOutputStream dataOutputStream;
final BufferedOutputStream out = new BufferedOutputStream(RRAWsecurity.socket.getOutputStream());
int count = data.length;
dataOutputStream = new DataOutputStream(RRAWsecurity.socket.getOutputStream());
dataOutputStream.writeInt(count);
dataOutputStream.flush();
out.write(data, 0, count);
out.flush();
}catch(Exception e)
{
e.printStackTrace();
}
return null;
}
}
问题在于这条线
out.write(data, 0, count);
错误说
The method write(byte[], int, int) in the type BufferedOutputStream is not applicable for the arguments (byte[][], int, int)
我不明白为什么它要求2D
数组?