Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.ArrayList;
- import java.util.Arrays;
- import java.util.List;
- import java.util.regex.Matcher;
- import java.util.regex.Pattern;
- public class Conversion {
- public static void main(String[] args) {
- List<Byte> ret = new ArrayList<Byte>();
- String s = "1234567890abcdef01234567890abcdef";
- Pattern p = Pattern.compile("..");
- Matcher m = p.matcher(s);
- while (m.find()) {
- char[] cs = m.group().toCharArray();
- int d = 0;
- for (int i = 0; i < cs.length; i++) {
- d = d * 16 + Character.digit(cs[i], 16);
- }
- ret.add((byte )d);
- }
- System.out.println(Arrays.toString(ret.toArray()));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement