Hi Friends This Program Will Demonstrate the Logic of Binary TO String Conversion....
Save The File BinarytoStr.java
import java.math.BigInteger;
class BinarytoStr
{
public static void main(String[] args)
{
String z = "0100100001100101011011000110110001101111";
int len = z.length()/8;
String orgstring = "";
byte[] bval = new BigInteger(z, 2).toByteArray();
for(int t = 0;t<len;t++)
{
char c1 = (char)bval[t];
orgstring = orgstring.concat(String.valueOf(c1));
}
System.out.println("Original String : " + orgstring);
}
}
OUTPUT :
Original String : Hello
I hope this logic will helpful to all...........
Save The File BinarytoStr.java
import java.math.BigInteger;
class BinarytoStr
{
public static void main(String[] args)
{
String z = "0100100001100101011011000110110001101111";
int len = z.length()/8;
String orgstring = "";
byte[] bval = new BigInteger(z, 2).toByteArray();
for(int t = 0;t<len;t++)
{
char c1 = (char)bval[t];
orgstring = orgstring.concat(String.valueOf(c1));
}
System.out.println("Original String : " + orgstring);
}
}
OUTPUT :
Original String : Hello
I hope this logic will helpful to all...........
EmoticonEmoticon