Java String to array of bytes wrong conversion -
Java String to array of bytes wrong conversion -
i have client server java code , client reading in string "input" , should decrypt it, decryption function needs array of bytes, need convert string array of bytes, done using "getbytes()" function, seems function modifying string! how can convert string array of bytes without changing content.
string input = inputline.substring(66, inputline.length()); system.out.println("read message +"+input+"+"); byte[] bx = input.getbytes(charset.forname("utf-8")); system.out.println("read message +"+bx.tostring()+"+"); system.out.println("read message +"+bx+"+");
the output of code snippet follows:
read message +[b@161cd475+
read message +[b@4e25154f+
read message +[b@4e25154f+
try writing loop print out results. believe java spitting out random memory value output.
(int = 0; s <= bx.length;i++) { system.out.println("read message +" + bx[i].tostring() + "+"); system.out.println("read message +" + bx + "+"); }
not sure if loop correct, may give work with. hope helps.
java string type-conversion bytearray
Comments
Post a Comment