【发布时间】:2014-04-05 19:10:22
【问题描述】:
我想从最初显示一些 html 的 url 下载文件,然后在 2-3 秒后显示下载对话框。显然,如果我这样做:
try {
URL url = new URL("http://my.url");
HttpURLConnection con = (HttpURLConnection) url.openConnection();
con.setRequestProperty("Connection", "Keep-Alive");
con.setRequestProperty("Content-Length",
Integer.toString(Integer.MAX_VALUE));
con.setReadTimeout(Integer.MAX_VALUE);
con.setConnectTimeout(Integer.MAX_VALUE);
con.connect();
bis = new BufferedInputStream(con.getInputStream(), 4096);
byteArray = IOUtils.toByteArray(bis);
FileUtils.writeByteArrayToFile(new File("myFile"), byteArray);
} catch (Exception e) {
}
我将保存显示的 .html 而不是保存对话框中显示的文件。 我应该如何更改代码才能做到这一点?
【问题讨论】:
标签: javascript java download