public static void resize(int buffer, int newByteSize) {

        if (newByteSize < 0) throw new NegativeArraySizeException();
        int buffPos = poses[buffer];
        int buffLength = lengths[buffer];
        lengths[buffer] = newByteSize;
        if (buffLength < newByteSize) {
            bytes = Arrays.copyOf(bytes, bytes.length + (newByteSize - buffLength));
        }
        int backLength = 0;
        for (int len = buffer + 1; len < lengths.length; ++len) {
            backLength += lengths[len];
        }
        for (int len = buffer + 1; len < poses.length; ++len) {
            poses[len] += newByteSize - buffLength;
        }
        System.arraycopy(bytes, buffPos + buffLength, bytes, buffPos + newByteSize, backLength);
        if (buffLength > newByteSize) {
            bytes = Arrays.copyOf(bytes, bytes.length + (buffLength - newByteSize));
        }
        System.out.println(bytes.length + ", " + (buffLength < newByteSize ? newByteSize - buffLength : buffLength - newByteSize));
        int length = (buffLength < newByteSize ? newByteSize - buffLength : buffLength - newByteSize);
        for (int len = 0; len < length; ++len) {
            bytes[buffPos + buffLength+ len] = 0;
        }
    }