Integer.toBinaryString(data)
gives me a binary String representation of my array data.
However I would like a simple way to add leading ze
would this satisfy your needs?
String dataStr = data == 0 ? "00" + Integer.toBinaryString(data) : Integer.toBinaryString(data);
edit: noticed the comment about dynamic length: probably some of the other answers are more suited:)