You are here

dns

How to get a DNS TXT record in Java

This guide applies to:
Java

Use this function to get the first txt record from DNS.

Example: String myTxtRecord = getTxtRecord("inprose.com");

public static String getTxtRecord(String hostName) {

    // Get the first TXT record

    java.util.Hashtable<String, String> env = new java.util.Hashtable<String, String>();
    env.put("java.naming.factory.initial", "com.sun.jndi.dns.DnsContextFactory");

Theme by Danetsoft and Danang Probo Sayekti inspired by Maksimer