Код выглядит так:
/*Введите байт и байт [] слияние в байт []*/ public byte [] bytemerger (byte byte_1, byte [] byte_2) {byte [] byte_3 = new byte [1 + byte_2.length]; byte_3 [0] = byte_1; System.ArrayCopy (byte_2, 0, byte_3, 1, byte_2.length); вернуть byte_3; } /*Введите байт [] и байт [] слияние в байт []* / public byte [] bytemerger (byte [] byte_1, byte [] byte_2) {byte [] byte_3 = new byte [1 + byte_2.length]; byte_3 [0] = byte_1; System.ArrayCopy (byte_2, 0, byte_3, byte_1.length, byte_2.length); вернуть byte_3; } /*Введите выходы строки (HEX, EG: FF) в Hex Byte [], Обратите внимание, что вход является строчной шестигранной строкой* / public byte [] hexstringtobyte (String hex) {int len = (hex.length () / 2); byte [] result = new Byte [len]; char [] achar = hex.tochararray (); for (int i = 0; i <len; i ++) {int pos = i * 2; Результат [i] = (byte) (chartobyte (achar [pos]) << 4 | chartobyte (achar [pos + 1])); } //System.out.println(Arrays.toString(Result)); результат возврата; } private byte chartobyte (char c) {// return (byte) "0123456789abcdef" .indexof (c); return (byte) "0123456789abcdef" .indexof (c); } /*Введите десятичную цифровую строку, выходную шестнадцатеричную строку (2 бита, например: f, выход 0f)* / string value = "100"; int parseint = integer.parseint (значение, 10); String hexstring = integer.tohexstring (parseint); if (hexstring.length () <2) {hexstring = '0' + hexstring; } Header = Header + HexString; } /*Входной шестнадцатеричный байт [] выход HexString* / public Static String BytearrayTohexstr (byte [] bytearray) {if (bytearray) == null) {return null; } char [] hexarray = "0123456789abcdef" .tchararray (); char [] hexchars = new char [bytearray.length * 2]; for (int j = 0; j <bytearray.length; j ++) {int v = bytearray [j] & 0xff; HexChars [j * 2] = hexarray [v >>> 4]; HexChars [j * 2 + 1] = hexarray [v & 0x0f]; } вернуть новую строку (hexchars); }PS: давайте посмотрим на преобразование JS в специальные персонажи в URL
let str = "http%3a%2f%2fxxxxxxx%2findex.php%2fxxxxxxx%2fmember%2frecister%3FRECOMMEND_ID%3D11442%26ID%3D87"; функция Replacestr (str) {str = str.replace (/%3a/g, ":"); str = str.replace (/%2f/g, "/"); str = str.replace (/%3f/g, "?"); str = str.replace (/%3d/g, "="); str = str.replace (/%26/g, "&"); str = str.replace (/%3f/g, "?"); str = str.replace (/%3d/g, "="); str = str.replace (/%26/g, "&"); str = str.replace (/%26/g, "&"); str = str.replace (/%2b/g, "+"); str = str.replace (/%20/g, ""); str = str.replace (/%23/g, "#"); вернуть Str; } console.log (Replacestr (str)); Суммировать
Выше приведено метод преобразования Byte [], String, Hex Strings и другой Java, который вам представил редактор. Я надеюсь, что это будет полезно для вас. Если у вас есть какие -либо вопросы, пожалуйста, оставьте мне сообщение, и редактор ответит вам вовремя. Большое спасибо за вашу поддержку сайту wulin.com!