Here you can find the source of getBinaryString(byte src)
Parameter | Description |
---|---|
src | a parameter |
public static String getBinaryString(byte src)
//package com.java2s; public class Main { /**/* w w w .j a v a2 s. c o m*/ * 7 => 00000111 * * @param src * @return */ public static String getBinaryString(long src) { String binaryString = Long.toBinaryString(src); String temp = ""; for (int i = 0; i < Long.SIZE - binaryString.length(); i++) { temp += "0"; } binaryString = temp + binaryString; return binaryString; } /** * 7 => 00000111 * * @param src * @return */ public static String getBinaryString(byte src) { String binaryString = Integer.toBinaryString(src); if (binaryString.length() > Byte.SIZE) { binaryString = binaryString.substring(binaryString.length() - Byte.SIZE); } else { String temp = ""; for (int i = 0; i < Byte.SIZE - binaryString.length(); i++) { temp += "0"; } binaryString = temp + binaryString; } return binaryString; } }