我有两个任务,一个用于下载,另一个用于解压缩;
public class DownloadUtil {
public static void downloadHtml(MainViewController controller, String dns, int port, String offlineUUID, String filePath, Map<String, String> cookies) throws IOException {
String urlHtml = "http://" + dns + ":" + port + Constants.TARGET_SERVICE_DOWNLOADFILES + offlineUUID;
System.out.println(urlHtml);
Executors.newSingleThreadExecutor().execute(new DownloaderTask(controller, urlHtml, filePath, cookies));
}
和
public class UnzipUtil {
public static void unZipIt(String zipFile, String outputFolder) {
Executors.newSingleThreadExecutor().execute(new UnzipTask(zipFile, outputFolder));
}
}
我在我的代码中这样称呼它们:
DownloadUtil.downloadHtml(this, dns, port, uuid, filePathHtmlDownload, cookies);
UnzipUtil.unZipIt(filePathHtmlDownload, outputFolder);
但问题是 Unzip 方法在下载方法完成之前调用,我该怎么做才能 unZipIt 等待 downloadHtml 方法?