private static String readName(DataInputStream dis,byte data[]) throws IOException {
  int c=dis.readUnsignedByte();
  if ((c & 0xc0) == 0xc0) {
    c=((c & 0x3f) << 8) + dis.readUnsignedByte();
    HashSet<Integer> jumps=new HashSet<Integer>();
    jumps.add(c);
    return readName(data,c,jumps);
  }
  if (c == 0) {
    return "";
  }
  byte b[]=new byte[c];
  dis.readFully(b);
  String s=IDN.toUnicode(new String(b));
  String t=readName(dis,data);
  if (t.length() > 0) {
    s=s + "." + t;
  }
  return s;
}

private static String readName ( DataInputStream dis , byte data [ ] ) throws IOException { int c = dis . readUnsignedByte ( ) ; if ( ( c & 0xc0 ) == 0xc0 ) { c = ( ( c & 0x3f ) << 8 ) + dis . readUnsignedByte ( ) ; HashSet < Integer > jumps = new HashSet < Integer > ( ) ; jumps . add ( c ) ; return readName ( data , c , jumps ) ; } if ( c == 0 ) { return "" ; } byte b [ ] = new byte [ c ] ; dis . readFully ( b ) ; String s = IDN . toUnicode ( new String ( b ) ) ; String t = readName ( dis , data ) ; if ( t . length ( ) > 0 ) { s = s + "." + t ; } return s ; }
parse a domain name starting at the current offset and moving the input stream pointer past this domain name ( even if cross references occure ) .
