- android - 多次调用 OnPrimaryClipChangedListener
- android - 无法更新 RecyclerView 中的 TextView 字段
- android.database.CursorIndexOutOfBoundsException : Index 0 requested, 光标大小为 0
- android - 使用 AppCompat 时,我们是否需要明确指定其 UI 组件(Spinner、EditText)颜色
我目前正在尝试找到一种通过 java 程序刷新我的 dns 缓存的方法。当我执行代码时,会出现命令提示符,但我不知道如何执行我的代码。
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintStream;
class SyncPipe implements Runnable
{
public SyncPipe(InputStream istrm, OutputStream ostrm) {
istrm_ = istrm;
ostrm_ = ostrm;
}
public void run() {
try
{
final byte[] buffer = new byte[1024];
for (int length = 0; (length = istrm_.read(buffer)) != -1; )
{
ostrm_.write(buffer, 0, length);
}
}
catch (Exception e)
{
e.printStackTrace();
}
}
private final OutputStream ostrm_;
private final InputStream istrm_;
}
public class FlushCommand {
FlushCommand(InputStream errorStream, PrintStream err) {
throw new UnsupportedOperationException("Not supported yet.");
}
}
这是下面的主要方法:
String command = "cmd /c start cmd.exe";
{
};
Process p = null;
try {// Execute command
Process child = Runtime.getRuntime().exec(command);
// Get output stream to write from it
OutputStream out = child.getOutputStream();
out.write("cd C:/ /r/n".getBytes());
out.flush();
out.write("dir /r/n".getBytes());
out.close();
p = Runtime.getRuntime().exec(command);
} catch (IOException ex) {
Logger.getLogger(FlushDNS.class.getName()).log(Level.SEVERE, null, ex);
}
new Thread((Runnable) new FlushCommand(p.getErrorStream(), System.err)).start();
new Thread((Runnable) new FlushCommnad(p.getInputStream(), System.out)).start();
PrintWriter stdin = new PrintWriter(p.getOutputStream());
stdin.println("dir c:\\ /A /Q");
stdin.println("ipconfig/flushdns");
// write any other commands you want here
stdin.close();
int returnCode = 0;
try {
returnCode = p.waitFor();
} catch (InterruptedException ex) {
Logger.getLogger(FlushDNS.class.getName()).log(Level.SEVERE, null, ex);
}
System.out.println("Return code = " + returnCode);
}
最佳答案
为什么不从最基本的开始呢?
您的命令只是打开一个命令窗口。如果我没记错的话,以下内容应该刷新您的 dns 并保持未关闭状态(cmd 不会自动关闭)。
String command = "cmd.exe /c start cmd.exe /c start ipconfig /flushdns";
try{
Runtime.getRuntime.exec(command);
catch(...){}
我必须检查计算机中的旧代码以确保确定,但我建议您从基础开始,然后进行多线程等。
或者,您可以使用进程构建器来创建命令。
关于java - 如何在java中刷新dns,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42801368/
我需要为一系列 Linux 容器运行本地 BIND DNS 服务器。假设区域是 example.com 我的基础架构中已经有一个 example.com 域,我想使用我的本地 DNS 服务器覆盖一些记
当“Google Public DNS”免费时,为什么要使用“Google Cloud DNS”? 如何设置 DNS/名称服务器以指向计算引擎: 1. 将您的域注册器(在我的情况下为 GoDaddy.
我有一些主机在 EC2 中按需出现,当它们执行启动它们的服务时,它们会在现有区域下的 Route53 中创建一条 A 记录。 A 记录的格式为:randomid.example.com。所以它不是现有
我目前拥有自己的域名和专用服务器,并且为我的客户提供不同的软件包。我希望能够做的是让他们在我的网站上注册并自动创建一个包,他们可以通过他们的用户名作为子域进行访问,例如 http://youruser
我想知道如何只为一级子域设置通配符 DNS,示例: user.example.com // valid www.user.example.com // invalid 我的 BIND 区域域配
我正在努力将我的域的名称服务器切换到新的 DNS 服务。 将新设置与现有 DNS 设置进行比较的最佳工具是什么。 我尝试使用带有和不带有 @nameserver 的 dig 来确保 DNS 记录在新旧
我是一名长期开发人员,但对 DNS 的经验并不丰富。这是我的问题: 我们的应用程序在 Amazon EC2 上为客户启动服务器。一个客户希望为每台启动的服务器使用自定义 DNS,而不是 AWS 提供的
Closed. This question is off-topic。它当前不接受答案。 想改善这个问题吗? Update the question,所以它是用于堆栈溢出的on-topic。 9年前关
我看到几个提到 DNS 名称(域名)的最大字符串长度为 253 个字符。维基百科似乎指的是这篇旧博文: https://en.wikipedia.org/wiki/Hostname http://bl
这可能是完全不可能实现的,但在我尝试之前,我想我可能会从一位极客那里得到一些建议。 Squid 也会代理 DNS 查询吗?我想转发DNS查询以通过squid并使用squid的DNS错误页面,当然是通过
在我的 Rails 应用程序中,我使用 ruby 库 resolv 进行 nslookup。如果输入像 dgdfgdfgdfg.com 这样的网站,则说明时间太长而无法解决。在某些情况下,例如 2
我正在研究一个带有每 5 秒刷新一次(轮询)的实时仪表板(Angular Web 应用程序)的场景。 API 位于 Azure 流量管理器之后,如果主要区域发生故障,它将故障转移到第二个区域。请记住,
我正在使用 fortify,它显示了攻击者可以在我尝试在 java 应用程序中获取主机名时进行 DNS 欺骗的漏洞。我有一个解决方案,通过匹配正向 DNS 和反向 DNS 条目可以避免这种情况。但它有
我正在尝试使用 cert-manager 为我的 istio-ingress-gateway 订购证书。为此,我在 AKS 上的 kubernetes 集群 (1.13.7) 上安装了 istio (
我正在尝试创建一个家庭自动化系统,它可以在我工作的白天照看我的狗。我在这个项目中的目标是学习一些关于 DNS、文件服务和 RaspberryPi 的知识。 我的硬件设置是这样的: 1 个 Raspbe
我想在一台服务器上创建一个 Web 界面,以管理另一台服务器上的几个 dns 服务器。 如何以编程方式远程管理绑定(bind) dns 服务器? 我想添加/编辑/删除区域。 我看到有 rndc,但它只
我对 TTL 和传播时间的概念有点困惑,我想澄清一些我没有设法在网上找到具体答案的事情。 AFAIK,TTL(生存时间)表示世界各地的服务器更新特定 DNS 的缓存值所需的(最高)时间。 所以...
我正在尝试学习 kubernetes,并且我已成功在裸机上设置集群(1 节点)、部署服务并通过入口公开它。 我尝试实现 traefik,以获取 Lets 加密证书,但我无法使其工作,并且在调试时我注意
我想以编程方式自动更新我的 DNS 多个域。我在 GoDaddy 上运行 BIND 服务器(在 FreeBSD 上)以及主机域和 DNS。我找不到供 GoDaddy 访问和更新他们托管的 DNS 的
我正在尝试记录 DNS“泄漏”,换句话说,我网站的访问者使用的 DNS 服务器。 如何确定网络请求来自哪个 DNS 服务器到我的服务器(即获取 DNS 泄漏)。本站 dnsleaktest.com是吗
我是一名优秀的程序员,十分优秀!