java byte数组拆分_将一个byte[]数组根据大小拆分为若干小byte[]数组方法

  • Post author:
  • Post category:java


///

/// 将大数组拆分为多个小数组

///

/// 需要拆分原始数组

/// 拆分后单个数组大小

///

public List SplitList(byte[] superbyte , int size)

{

List result = new List();

int length = superbyte.Length;

int count = length / size;

int r = length % size;

for (int i = 0; i < count; i++)

{

byte[] newbyte = new byte[size];

newbyte = superbyte.Skip(size * i).Take(size).ToArray();// SplitArray(superbyte, size*i, size * i+ size);

result.Add(newbyte);

}

if (r != 0)

{

byte[] newbyte = new byte[r];

newbyte = superbyte.Skip(length – r).Take(r).ToArray();

result.Add(newbyte);

}

return result;

}



版权声明:本文为weixin_39788969原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。