package com.timgroup.zmtp;

public class FrameTestUtils {

    public static final int FINAL = 0;
    public static final int MORE = 1;

    public static byte[] concatenate(byte[] a, byte[] b) {
        byte[] c = new byte[a.length + b.length];
        System.arraycopy(a, 0, c, 0, a.length);
        System.arraycopy(b, 0, c, a.length, b.length);
        return c;
    }

    public static byte[] longFrame(int lengthFlag, int l0, int l1, int l2, int l3, int l4, int l5, int l6, int l7, int flags, byte[] body) {
        byte[] header = new byte[] {(byte) lengthFlag, (byte) l0, (byte) l1, (byte) l2, (byte) l3, (byte) l4, (byte) l5, (byte) l6, (byte) l7, (byte) flags};
        return concatenate(header, body);
    }

    public static byte[] shortFrame(int length, int flags, byte[] body) {
        byte[] header = new byte[] {(byte) length, (byte) flags};
        return concatenate(header, body);
    }

}

@@ -177,23 +177,125 @@
 te%5B%5D
- a, byte%5B%5D b) %7B
+... parts) %7B%0A        int length = 0;%0A        for (byte%5B%5D part : parts) %7B%0A            length += part.length;%0A        %7D
 %0A   
@@ -306,17 +306,21 @@
  byte%5B%5D 
-c
+whole
  = new b
@@ -327,78 +327,78 @@
 yte%5B
-a.
 length
- + b.length%5D;%0A        System.arraycopy(a, 0, c, 0, a.length);%0A
+%5D;%0A        int off = 0;%0A        for (byte%5B%5D part : parts) %7B%0A    
     
@@ -422,38 +422,85 @@
 opy(
-b
+part
 , 0, 
-c, a.length, b
+whole, off, part.length);%0A            off += part
 .length
-)
 ;%0A
+        %7D%0A
     
@@ -510,17 +510,21 @@
  return 
-c
+whole
 ;%0A    %7D%0A

Generalise a utility method