Here you can find the source of getBytes(int value)
private static byte[] getBytes(int value)
//package com.java2s; //License from project: Apache License import java.io.ByteArrayOutputStream; public class Main { private static byte[] getBytes(int value) { if ((value >= 0x20 && value <= 0x7F) || (value >= 0xA0 && value <= 0xDF)) { return new byte[] { (byte) value }; } else {//from w ww . ja v a 2 s. c om ByteArrayOutputStream baos = new ByteArrayOutputStream(); int high = (byte) ((value >>> 8) & 0xFF); int low = (byte) ((0xFF & value)); baos.write(high); baos.write(low); return baos.toByteArray(); } } }