private Answer parseAnswer(String str, int begin)
    {
    	int cur = begin;
        Query qu = parseQuery(str, cur);
        cur += qu.length;
        int ttl = Str4ToInt(str.substring(cur,cur+4));
        cur += 4;
        int len = Str2ToInt(str.substring(cur,cur+2));
        cur += 2;
        String aRes = "";
        int priority = 0;
        switch(qu.type){
	        case A_QUERY_TYPE:{
	        	if(len==4){
	        		aRes = Integer.toString(str.codePointAt(cur))+"."+Integer.toString(str.codePointAt(cur+1))+"."+Integer.toString(str.codePointAt(cur+2))+"."+Integer.toString(str.codePointAt(cur+3));
	        	}
	        	break;
	        }
	        case PTR_QUERY_TYPE:
	        case CNAME_QUERY_TYPE:{
	        	DName dname = parseDomainName(str, cur);
	        	aRes = dname.name;
	        	break;
	        }
	        case HINFO_QUERY_TYPE:{
	        	int hilen = str.codePointAt(cur);
	        	aRes = str.substring(cur+1,cur+hilen+1);
	        	break;
	        }
	        case MX_QUERY_TYPE:{
	        	priority = Str2ToInt(str.substring(cur,cur+2));
	        	DName dname = parseDomainName(str, cur+2);
	        	aRes = dname.name;
	        	break;
	        }
        }
        cur += len;        
        return new Answer(qu.name,qu.type,ttl,aRes,priority,cur-begin);
    }