gpt4 book ai didi

java - 向 Windows 控制台发送命令确认

转载 作者:太空宇宙 更新时间:2023-11-04 13:20:08 25 4
gpt4 key购买 nike

我已经成功地从 java 调用 Windows 控制台来使用 zlib 解压缩字符串,如下所示:

    Runtime rt = Runtime.getRuntime();
rt.exec("cmd.exe /c start z -d psw.txt", null, new File("C:\\users\\dlopez\\Encrypted\\ "));

在此之后,我被问到是否要覆盖该文件,我必须表示"is",但在执行命令后我不知道如何从 java 中执行此操作。

我该怎么做?

谢谢

最佳答案

您可以像这样响应控制台提示:

        Runtime rt = Runtime.getRuntime();
Process proc = rt.exec("cmd.exe /c start z -d psw.txt", null, new File("C:\\users\\dlopez\\Encrypted\\ "));
new PrintWriter(proc.getOutputStream()).println("y");

关于java - 向 Windows 控制台发送命令确认,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33146004/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com