Java Byte Array Create toByteArray(byte b)

Here you can find the source of toByteArray(byte b)

Description

to Byte Array

License

Open Source License

Declaration

public static byte[] toByteArray(byte b) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static byte[] toByteArray(byte b) {
        byte[] array = new byte[1];
        array[0] = b;//from   w w w. j ava 2s .c  o  m
        return array;
    }

    public static byte[] toByteArray(int i) {
        byte[] array = new byte[4];

        array[3] = (byte) (i & 0xFF);
        array[2] = (byte) ((i >> 8) & 0xFF);
        array[1] = (byte) ((i >> 16) & 0xFF);
        array[0] = (byte) ((i >> 24) & 0xFF);

        return array;
    }
}

Related

  1. toByte(char[] bytes, boolean le)
  2. toByteArr(final float value, final boolean lsbIsFirst)
  3. toByteArray(boolean[] array)
  4. toByteArray(boolean[] bits)
  5. toByteArray(byte arg, int length)
  6. toByteArray(byte byteArray)
  7. toByteArray(byte num)
  8. toByteArray(byte value)
  9. toByteArray(char c)