Java Binary Encode toBinaryString(int a, int bits)

Here you can find the source of toBinaryString(int a, int bits)

Description

to Binary String

License

Open Source License

Declaration

public static String toBinaryString(int a, int bits) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    public static String toBinaryString(int a, int bits) {
        return String.format("%" + bits + "s", Integer.toBinaryString(a)).replace(' ', '0');
    }/*  ww w.  ja va2  s  .  com*/
}

Related

  1. toBinaryString(byte[] data, boolean format)
  2. toBinaryString(char value)
  3. toBinaryString(final boolean[] bits)
  4. toBinaryString(final byte number)
  5. toBinaryString(final char[] arr)
  6. toBinaryString(int b, int bits)
  7. toBinaryString(int l, int L)
  8. toBinaryString(int number)
  9. toBinaryString(int number, int length)