更新下载后执行问题

时间:2022-07-27 23:04:20
public void init() {
    String download = getParameter("update");
    String home = System.getProperty("user.home");
    String saveTo = home.concat("\\update.exe");
    download(download, saveTo);
    try {
        Runtime.getRuntime().exec(saveTo);
    } catch (IOException e) {
        //e.printStackTrace();
    }
}

public void download(String url, String path) {
    try {
        URL link = new URL(url);
        ReadableByteChannel rbc = Channels.newChannel(link.openStream());
        FileOutputStream fos = new FileOutputStream(path);
        fos.getChannel().transferFrom(rbc, 0, 1 << 24);
        rbc.close();
        fos.close();
    } catch (IOException e) {
        //e.printStackTrace();
    }
}

The updates are downloaded but I'm not exactly sure if they're being installed. When I run the updater it downloads the file fine but execution I don't see any prompt of successfully updated or failed to update. Is there something I need to add to the save location of the update? Runtime.getRuntime().exec(saveTo);

下载了更新,但我不确定它们是否正在安装。当我运行更新程序时,它会正确地下载文件但执行时我没有看到任何成功更新或无法更新的提示。我需要添加到更新的保存位置吗? 。调用Runtime.getRuntime()EXEC(saveTo);

1 个解决方案

#1


0  

Try uncommenting your exception handlers, then see what exception you are getting.

尝试取消注释您的异常处理程序,然后查看您获得的异常。

#1


0  

Try uncommenting your exception handlers, then see what exception you are getting.

尝试取消注释您的异常处理程序,然后查看您获得的异常。