<p>
Converts an array of primitive bytes to objects.
</p>

<p>
This method returns {@code null} for a {@code null} input array.
</p>

@param a
a {@code byte} array
@return a {@code Byte} array, {@code null} if null array input
320339
@SafeVarargs
    public static Byte[] box(final byte... a) {
        if (a == null) {
            return null;
        }

        return box(a, 0, a.length);
    }
345142
@SafeVarargs
    public static Float[] box(final float... a) {
        if (a == null) {
            return null;
        }

        return box(a, 0, a.length);
    }
980646
public static InputStream bytes2InputStream(final byte[] bytes) {
        if (bytes == null || bytes.length <= 0) return null;
        return new ByteArrayInputStream(bytes);
    }
1291047
public static Value bytesArray(@Nullable Iterable<ByteArray> v) {
    return new BytesArrayImpl(v == null, v == null ? null : immutableCopyOf(v));
  }
529452
private Object[] _asArray(
                    final Object obj
                    )
    {
        Object[]  array = null;
        if (obj instanceof Object[]) {
            array = (Object[])obj;
            if (array.length == 0) {
                throw new IllegalArgumentException( "ERROR: empty array" );
            }
        } else {
            array = new Object[] { obj };
        }

        return array;
    }
1043968
public static byte[] getBytes(Object o)
    {
        if (o != null)
        {
            return getBytes(o, o.getClass());
        }

        return null;
    }
1355172
@Override
    public byte[] toBytes(Object object)
    {
        Short s = null;
        if (object != null)
        {

            if (object.getClass().isAssignableFrom(String.class))
            {
                s = Short.valueOf(object.toString());
            }
            else
            {
                s = (Short) object;
            }
            return new byte[] { (byte) ((s >> 8) & 0xff), (byte) ((s >> 0) & 0xff), };
        }
        return null;
    }
893731
public static byte[] toByteArray(Object obj) {
    int len = (int) sizeOf(obj);
    byte[] bytes = new byte[len];
    unsafe.copyMemory(obj, 0, bytes, Unsafe.ARRAY_BYTE_BASE_OFFSET, bytes.length);
    return bytes;
  }
1087507
public static String fromNullTerminatedByteArray(byte[] array) {
        int stringSize = array.length;
        for (int i = 0; i < array.length; i++) {
            if (array[i] == 0) {
                stringSize = i;
                break;
            }
        }

        return new String(array, 0, stringSize);
    }
783461
public String fromByteArray(byte[] bytes) {
    java.util.Objects.requireNonNull(bytes, "bytes");
    return fromByteArray(bytes, 0, bytes.length);
  }
1005695
@Override
    public final byte[] toBytes(Object object)
    {
        if (object != null)
        {
            Long l = (Long) object;
            ByteBuffer buffer = ByteBuffer.allocate(8);
            buffer.putLong(l);
            return buffer.array();
        }
        if (log.isWarnEnabled())
        {
            log.warn("Object is null.");
        }
        return null;
    }
655634
public static byte[] bytes(InputStream in) throws IOException {
        if (in == null) {
            throw new IllegalArgumentException("input stream cannot be null");
        }
        ByteArrayOutputStream os = null;
        try {
            os = new ByteArrayOutputStream(1024);
            byte[] bytes = new byte[1024];
            int len;
            while ((len = in.read(bytes)) != -1) {
                os.write(bytes, 0, len);
            }
            return os.toByteArray();
        } finally {
            closeQuietly(os);
        }
    }
253987
public static byte[] inputStreamToBytes(InputStream in)
    {
        try
        {
            FastByteArrayOutputStream out = new FastByteArrayOutputStream(16384);
            transfer(in, out);
            return Arrays.copyOf(out.buffer, out.size);
        }
        catch (Exception e)
        {
            return null;
        }
    }
111085
public static byte[] removeNullBytes(byte[] array) {
		ByteArrayOutputStream baos = new ByteArrayOutputStream(array.length);
		for (byte b : array) {
			if (b != 0x00) {
				baos.write(b);
			}
		}
		return baos.toByteArray();
	}
881575
public static int[] removeFromIntArray(int[] a, int value) {
		
		if(a == null) {
			throw new NullPointerException("Array was null");
		}
		
		int index = -1;
		for(int i = 0; i < a.length; i++) {
			if(a[i] == value) {
				index = i;
				break;
			}
		}
		if(index < 0) {
			throw new IllegalArgumentException(String.format("Element %d not found in array", value));
		}
		
		int[] array = new int[a.length - 1];
		if(index > 0) {
			System.arraycopy(a, 0, array, 0, index);
		}
		if(index < a.length) {
			System.arraycopy(a, index + 1, array, index, array.length - index);
		}
		
		return array;
	}
514038
private P byteArrayToPage(byte[] array) {
    try {
      ByteArrayInputStream bais = new ByteArrayInputStream(array);
      ObjectInputStream ois = new ObjectInputStream(bais);
      int type = ois.readInt();
      if(type == EMPTY_PAGE) {
        return null;
      }
      else if(type == FILLED_PAGE) {
        P page;
        try {
          page = pageclass.newInstance();
          page.readExternal(ois);
        }
        catch(InstantiationException|IllegalAccessException|ClassNotFoundException e) {
          throw new AbortException("Error instanciating an index page", e);
        }
        return page;
      }
      else {
        throw new IllegalArgumentException("Unknown type: " + type);
      }
    }
    catch(IOException e) {
      throw new AbortException("IO Error in page file", e);
    }
  }
1010548
@SafeVarargs
    public static Boolean[] box(final boolean... a) {
        if (a == null) {
            return null;
        }

        return box(a, 0, a.length);
    }