Here you can find the source of getBytes(byte value)
public static byte[] getBytes(byte value) throws IOException
//package com.java2s; //License from project: Apache License import java.io.IOException; public class Main { public static byte[] getBytes(byte value) throws IOException { byte[] byteArray = new byte[1]; byteArray[0] = value;/*from www . j a va2 s .c o m*/ return byteArray; } public static byte[] getBytes(int value, int length) throws IOException { return getBytes((long) value, length); } public static byte[] getBytes(long value, int length) throws IOException { byte[] b = new byte[length]; for (int i = 0; i < length; i++) { int offset = (b.length - 1 - i) * 8; b[i] = (byte) ((value >> offset) & 0xFF); } return b; } }