Search This Blog

Friday, September 25, 2020

Java Contains Byte String - Back to Original Content String from Byte Array String

Code


String str = "hello";
byte [] x = str.getBytes ();
System.out.println ( new String (x) );
String byStr = "104, 101, 108, 108, 111";
String a [] = byStr.split ( "," );
byte xx [] = new byte[a.length];
int count = 0;
for ( String s :  a)
{
xx[count++] = Byte.parseByte ( s.trim () );
}
System.out.println ( new String (xx) );


Output

hello

hello




No comments:

Hit Counter


View My Stats