How can i divide a hex string into two parts?
it is possible to divide an hexadecimal srting in two part开发者_如何学Pythons,specifically i have the string variable take values like that var=xxxxyyyy.I need to divide this in two parts,on var1=xxxx and var2=yyyy how can implemented this in java?
String hex = "AAAABBBB";
String part1 = hex.substring(0, 4);
String part2 = hex.substring(4);
If you want to split a string to two equal parts, you can do:
String myString = "xxxxyyyy";
String firstPart = myString.substring(0, myString.length() / 2);
String secondPart = myString.substring(myString.length() / 2);
精彩评论