how to store a byte [] into a single variable in android/java -
i have string str = "admin:admin"
i want convert in ascii.
i have tried str.getbyte("us-ascii");
returning me byte[] array (i.e [97, 100, 109, 105, 110, 58, 97, 100, 109, 105, 110]
). want ascii value in single string variable. how can this.
simple want string strascii = "971001091051105897100109105110"
is possible?
i tried this
stringbuilder builder = new stringbuilder(); (int i=0; i<=b.length; i++) { builder.append(b); } string result = builder.tostring();
but returning me this
[b@405666e0[b@405666e0[b@405666e0[b@405666e0[b@405666e0[b@405666e0[b@405666e0[b@405666e0[b@405666e0[b@405666e0[b@405666e0[b@405666e0
what this?
try looping stringbuilder
:
stringbuilder builder = new stringbuilder(); (byte b : arr) { builder.append(b); } string result = builder.tostring();
you could, of course, same thing string concatenation, using stringbuilder
explicitly faster lots of little appends.
java android type-conversion bytearray
No comments:
Post a Comment