Method of cleaning DNS cache with Java
•
Java
This article describes the method of cleaning DNS cache with Java. Share with you for your reference. The specific analysis is as follows:
1、 Test environment
OS:Windows7 x64
JDK:1.6. 0_ forty-five
2、 I have found four ways to clean up the DNS cache of the JVM, which you can choose according to your own situation.
1. Call InetAddress for the first time Before getbyname(), set Java security. Security. setProperty("networkaddress.cache.ttl","0"); 2. Modify JRE / lib / security / Java Networkaddress under security cache. TTL attribute 3 Set - dsun. In the JVM startup parameters net. inetaddr. ttl=0 4. Through reflection cleaning, such as the clearcache method in this article
3、 Code
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码