Groovy web console

subscribe to the feed Subscribe
to this
site

convertStringToBinary

Published 1 month ago by Ram with tags to binary
Actions  ➤ Edit in console Back to console Show/hide line numbers View recent scripts
String str = "Rama"

byte[] b = str.getBytes()

byte b1 = (byte) 129; 
String s1 = String.format("%8s", Integer.toBinaryString(b1 & 0xFF)).replace(' ', '0'); 
System.out.println(s1);