Here you can find the source of toBinary(short value)
public static String toBinary(short value)
//package com.java2s; //License from project: Open Source License public class Main { public static String toBinary(short value) { return String.format("%16s", Integer.toString(value & 0xFFFF, 2)).replace(' ', '0'); }//from w w w .ja v a 2 s . c om public static String toBinary(byte value) { return String.format("%8s", Integer.toString(value & 0xFF, 2)).replace(' ', '0'); } }