我正在尝试从我的Glassfish服务器上下载Android的Chrome上的.APK,但我得到的只是一个“零 kb”文件。
在Windows(PC)的Chrome和Android的Firefox上,它可以正常运行。
我正在使用以下代码:
private void downloadAPK(HttpServletRequest request, HttpServletResponse response, PrintWriter out){
String file = "/usr/local/glassfish4/glassfish/domains/domain1/applications/foo/foo.apk";
FileInputStream inputStream = null;
try{
File downloadFile = new File(file);
inputStream = new FileInputStream(downloadFile);
response.setHeader("Content-Disposition","attachment;filename="+file.getName());
int c = 0;
while ((c = inputStream.read()) != -1)
out.write(c);
} catch (Exception e) {
// code
}
// closing code
}
我还缺少一些能让它在Android Chrome上运行的东西吗?