Created
December 11, 2014 06:07
-
-
Save dbaba/b6318772c6d67d3eba24 to your computer and use it in GitHub Desktop.
Fetching TXT records with dnsjava
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| final Lookup lookup = new Lookup("my-txt.example.com", Type.TXT); | |
| lookup.setResolver(new SimpleResolver()); | |
| lookup.setCache(null); | |
| final Record[] records = lookup.run(); | |
| if (lookup.getResult() == Lookup.SUCCESSFUL) { | |
| final StringBuilder builder = new StringBuilder(); | |
| for (Record record : records) { | |
| final TXTRecord txt = (TXTRecord) record; | |
| builder.delete(0, builder.length()); | |
| for (@SuppressWarnings("unchecked") | |
| Iterator<String> iterator = txt.getStrings().iterator(); iterator | |
| .hasNext();) { | |
| builder.append(iterator.next()); | |
| } | |
| final String txt = builder.toString(); | |
| // TODO | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Please add imports to your code. Because when I try to import from eclipse there are like 10 import options available for each error.