How to get 0-padded binary representation of an integer in java? November 28, 2022 by Tarik I think this is a suboptimal solution, but you could do String.format("%16s", Integer.toBinaryString(1)).replace(' ', '0')