Android Utililty Methods Byte Array Convert From

List of utility methods to do Byte Array Convert From

Description

The list of methods to do Byte Array Convert From are organized into topic(s).

Method

byte[]toByteArray(Bundle bundle)
to Byte Array
Parcel obtain = Parcel.obtain();
bundle.writeToParcel(obtain, 0);
byte[] byteArray = obtain.marshall();
obtain.recycle();
return byteArray;
byte[]toByteArray(ContentValues contentValues)
to Byte Array
Parcel obtain = Parcel.obtain();
contentValues.writeToParcel(obtain, 0);
byte[] byteArray = obtain.marshall();
obtain.recycle();
return byteArray;
byte[]toByteArray(Number... numbers)
Convert a variadic list of Number s into a byte array using native endian order.
if (numbers.length == 0) {
    throw new IllegalArgumentException("too few numbers");
if (VERBOSE)
    Log.v(TAG, "toByteArray - input: " + Arrays.toString(numbers));
ByteBuffer byteBuffer = ByteBuffer.allocate(
        numbers.length * (Double.SIZE / Byte.SIZE)).order(
        ByteOrder.nativeOrder());
...
byte[]toByteArray(Serializable serializable)
to Byte Array
ByteArrayOutputStream bos = new ByteArrayOutputStream();
ObjectOutput out = null;
try {
    out = new ObjectOutputStream(bos);
    out.writeObject(serializable);
    byte[] bytes = bos.toByteArray();
    return bytes;
} catch (IOException e) {
...
byte[]toByteArray(Spanned spanned)
to Byte Array
Parcel obtain = Parcel.obtain();
TextUtils.writeToParcel(spanned, obtain, 0);
byte[] byteArray = obtain.marshall();
obtain.recycle();
return byteArray;
byte[]toByteArray(T array)
Convert an array of primitives to a byte[] using native endian order.
@SuppressWarnings("unchecked")
Class<T> klass = (Class<T>) array.getClass();
if (!klass.isArray()) {
    throw new IllegalArgumentException(
            "array class must be an array");
Class<?> componentClass = klass.getComponentType();
if (!componentClass.isPrimitive()) {
...
byte[]toByteArray(T array, int sizeOfTBits)
to Byte Array
@SuppressWarnings("unchecked")
Class<T> klass = (Class<T>) array.getClass();
if (!klass.isArray()) {
    throw new IllegalArgumentException(
            "array class must be an array");
int sizeOfT = sizeOfTBits / Byte.SIZE;
int byteLength = Array.getLength(array) * sizeOfT;
...
byte[]toByteArray(byte[] array)
Convert an array of byte primitives to a byte[] using native endian order.
return array;
byte[]toByteArray(char[] array)
Convert an array of chars to a byte[] using native endian order.
return toByteArray(array, Character.SIZE);
byte[]toByteArray(double[] array)
Convert an array of doubles to a byte[] using native endian order.
return toByteArray(array, Double.SIZE);