public DNSRR readRR() throws IOException {
        String rrName = readDomainName();
        int rrType = readShort();
        int rrClass = readShort();
        long rrTTL = readInt();
        int rrDataLen = readShort();
        DNSInputStream rrDNSIn = new DNSInputStream(buf, pos, rrDataLen);
        pos += rrDataLen;
        try {
            String myName = getClass().getName();
            int periodIndex = myName.lastIndexOf('.');
            String myPackage = myName.substring(0, 1 + periodIndex);

            Class<?> theClass = Class.forName(myPackage + "record." + DNS.typeName(rrType));
            DNSRR rr = (DNSRR) theClass.newInstance();
            if (rrType != DNS.TYPE_TXT) {
                rr.init(rrName, rrType, rrClass, rrTTL, rrDNSIn);
            }
            return rr;
        } catch (ClassNotFoundException ex) {
            throw new IOException("Unknown DNSRR (type "
                    + DNS.typeName(rrType) + " (" + rrType + "))");
        } catch (IllegalAccessException ex) {
            throw new IOException("Access error creating DNSRR (type "
                    + DNS.typeName(rrType) + ')');
        } catch (InstantiationException ex) {
            throw new IOException("Instantiation error creating DNSRR (type "
                    + DNS.typeName(rrType) + ')');
        }
    }