I need to convert a String value into Binary format. For Example: String str = "Java"; now i want to get it in binary format.how could i do this? any one could please help me!
Thanks in advane
I need to convert a String value into Binary format. For Example: String str = "Java"; now i want to get it in binary format.how could i do this? any one could please help me!
Thanks in advane
Try this,
byte[] infoBin = null;
infoBin = "Java".getBytes("UTF-8");
for (byte b : infoBin) {
System.out.println("c:" + (char) b + "-> "
+ Integer.toBinaryString(b));
}
See this link : String to binary output in Java
Try this
byte[] bytes = str.getBytes(charSetName);
this encodes str into a sequence of bytes using the named charset, storing the result into a byte array.
following will give you byte code;
String str = "Java";
byte[] bytecode=str.getBytes();