private static String readName(byte data[],int offset,HashSet<Integer> jumps) throws IOException {
  int c=data[offset] & 0xff;
  if ((c & 0xc0) == 0xc0) {
    c=((c & 0x3f) << 8) + (data[offset + 1] & 0xff);
    if (jumps.contains(c)) {
      throw new DnsException("","Cyclic offsets detected.");
    }
    jumps.add(c);
    return readName(data,c,jumps);
  }
  if (c == 0) {
    return "";
  }
  String s=new String(data,offset + 1,c);
  String t=readName(data,offset + 1 + c,jumps);
  if (t.length() > 0) {
    s=s + "." + t;
  }
  return s;
}

private static String readName ( byte data [ ] , int offset , HashSet < Integer > jumps ) throws IOException { int c = data [ offset ] & 0xff ; if ( ( c & 0xc0 ) == 0xc0 ) { c = ( ( c & 0x3f ) << 8 ) + ( data [ offset + 1 ] & 0xff ) ; if ( jumps . contains ( c ) ) { throw new DnsException ( "" , "Cyclic offsets detected." ) ; } jumps . add ( c ) ; return readName ( data , c , jumps ) ; } if ( c == 0 ) { return "" ; } String s = new String ( data , offset + 1 , c ) ; String t = readName ( data , offset + 1 + c , jumps ) ; if ( t . length ( ) > 0 ) { s = s + "." + t ; } return s ; }
parse a domain name starting at the given offset .
