简体   繁体   中英

how to convert ascii to byte array format

i want to convert the ascii code to byte array format:

Code :

byte[] byteArr = passenger_sign.getBytes();

Output :

[B@34c59da

i dont know how to convert it to byte array format,anyone have solution for this.

Refer this link [ https://examples.javacodegeeks.com/core-java/lang/string/convert-string-to-byte-array-ascii-encoding/]

public static byte[] stringToBytesASCII(String str) {
 byte[] b = new byte[str.length()];
 for (int i = 0; i < b.length; i++) {
  b[i] = (byte) str.charAt(i);
 }
 return b;
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM