title: How to make Integer.toBinaryString return at least 4 bits
body: <p>I am writing a method where I am converting int values into binary strings and storing them. I am using the method Integer.toBinaryString to do so, and it's working correctly, but the problem is that I need the method to return exactly 4 bits in the string instead of less (it will never be more because the numbers are not large enough). Here is an example of my code and where the problem is occurring:</p>
  
  <pre><code>int value5 = 3;
  String strValue5 = Integer.toBinaryString(value5);
  for(int index = 0; index &lt; 4; index++){
       sBoxPostPass[4][index] = strVal5.charAt(index);
  }
  </code></pre>
  
  <p>Clearly, this will throw an ArrayOutOfBoundsException because <code>strValue5 == 11</code> and not <code>0011</code>, like it needs to be. I hope this is sufficiently clear. Thanks in advance for the help.</p>