java - divide array into smaller parts -


I want to divide a large byte array into smaller sections (say 64 bytes). Please help me with this.

You can use the method Arrays.copyOfRange (from the original, from)

  public static byte [] [] divideArray (byte [] source, int chunksize) {byte [] [] ret = new byte [(int) Math.ceil (source.length / (double) chunksize) ] [ chunk size]; Int start = 0; For (int i = 0; i & lt; ret.length; i ++) {rate = i] = Arrays.copyOfRange (source, start, start + chunksize); Start + = selected; } Return return; }  

Or you can suggest Max to the system. Arrecopy

  public static byte [] [] divideArray (byte [] source, int chunksize) {byte [] [] rate = new byte [(int) math. Cecil (source length / (double) selective)] [chanaxes]; Int start = 0; For (int i = 0; i & lt; ret.length; i ++) {if (start + chunksize> source.length) {System.arraycopy (source, start, write [i], 0, source Length - start); } Else {System.arraycopy (source, start, write [i], 0, chocex); } Start + = selected; } Return return; }  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -