content: package com.feihong.ldap.gadgets.utils;
  
  public class Util {
      public static byte[] deleteAt(byte[] bs, int index) {
          int length = bs.length - 1;
          byte[] ret = new byte[length];
  
          if(index == bs.length - 1) {
              System.arraycopy(bs, 0, ret, 0, length);
          } else if(index < bs.length - 1) {
              for(int i = index; i < length; i++) {
                  bs[i] = bs[i + 1];
              }
  
              System.arraycopy(bs, 0, ret, 0, length);
          }
  
          return ret;
      }
  
      public static byte[] addAtIndex(byte[] bs, int index, byte b) {
          int length = bs.length + 1;
          byte[] ret = new byte[length];
  
          System.arraycopy(bs, 0, ret, 0, index);
          ret[index] = b;
          System.arraycopy(bs, index, ret, index + 1, length - index - 1);
  
          return ret;
      }
  
      public static byte[] addAtLast(byte[] bs, byte b) {
          int length = bs.length + 1;
          byte[] ret = new byte[length];
  
          System.arraycopy(bs, 0, ret, 0, length-1);
          ret[length - 1] = b;
  
          return ret;
      }
  }
  