In our application sometime there is need of byte array. We can use byte array for encryption purpose . We can convert a string to byte array using string getBytes() method. In byte array string become in decryted format . We can make string from byte array using this syntax.
String str = new String(ByteArray);
package com.javaproficiency;
public class StringToBinary {
public static void main(String[] args) {
String IPCode = "java string is good";
//convert string to byte array
byte [] bytes = IPCode.getBytes();
System.out.println(" string ="+ IPCode);
System.out.println(" byte array ="+ bytes);
//Convert byte array to string
String str = new String( bytes );
System.out.println(" str ="+ str);
}
}
Output:
string =java string is good
byte array =[B@6c267f18
str =java string is good
Learning new technolgoy would help oneself at hard part of their career. And staying updated is the only way to survive in current position. Your content tells the same. Thanks for sharing this information in here. Keep blogging like this.
ReplyDeleteJAVA Training in Chennai | Mobile application testing training in Chennai | Hadoop training in chennai
thanks for sharing such a wonderful blog
ReplyDeleteBest Selenium Training in Chennai | Android Training in Chennai | Java Training in chennai | Webdesigning Training in Chennai
nice and really helpful article to everyone... thanks for sharing
ReplyDeleteselenium training in chennai | selenium training institute in chennai | Android training in chennai | android training institute in chennai
good one
ReplyDeleteBest Selenium Training Center in chennai | Best Automation Testing Training in Chennai