public static byte[] toByteArray(String str){
  int len=str.length();
  StringTokenizer st=new StringTokenizer(str,":");
  String[] newStrArray=new String[st.countTokens()];
  int j=0;
  while (st.hasMoreTokens()) {
    newStrArray[j]=st.nextToken();
    j++;
  }
  byte[] ret=new byte[newStrArray.length];
  int tmp;
  for (int i=0; i < newStrArray.length; i++) {
    tmp=Integer.parseInt(newStrArray[i],16);
    ret[i]=(byte)(tmp - 128);
  }
  return ret;
}

public static byte [ ] toByteArray ( String str ) { int len = str . length ( ) ; StringTokenizer st = new StringTokenizer ( str , ":" ) ; String [ ] newStrArray = new String [ st . countTokens ( ) ] ; int j = 0 ; while ( st . hasMoreTokens ( ) ) { newStrArray [ j ] = st . nextToken ( ) ; j ++ ; } byte [ ] ret = new byte [ newStrArray . length ] ; int tmp ; for ( int i = 0 ; i < newStrArray . length ; i ++ ) { tmp = Integer . parseInt ( newStrArray [ i ] , 16 ) ; ret [ i ] = ( byte ) ( tmp - 128 ) ; } return ret ; }
converts a given hex string separated by colons to a byte array .
