Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/apache/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
从HTTPS URL下载大型文件时的Java问题_Java_Apache_Tomcat_Ssl_Ssl Certificate - Fatal编程技术网

从HTTPS URL下载大型文件时的Java问题

从HTTPS URL下载大型文件时的Java问题,java,apache,tomcat,ssl,ssl-certificate,Java,Apache,Tomcat,Ssl,Ssl Certificate,我在从“HTTPS URL”下载文件(超过200mb大小)时遇到问题。 问题在于认证和下载问题。我还使用了信任管理器,SSL安全等代码。但问题仍然存在,主要是因为我无法通过证书 例如:我的HTTPS URL是:-https://v1/xyz/abc.avi。现在我想下载这个文件,但无法下载。正在从我的应用程序的以下代码下载小文件:- .....if (contentLength > 0) { try { InputStream in = urlCo

我在从“HTTPS URL”下载文件(超过200mb大小)时遇到问题。 问题在于认证和下载问题。我还使用了信任管理器SSL安全等代码。但问题仍然存在,主要是因为我无法通过证书

例如:我的HTTPS URL是:-
https://v1/xyz/abc.avi
。现在我想下载这个文件,但无法下载。正在从我的应用程序的以下代码下载小文件:-

.....if (contentLength > 0) {  
       try {  
          InputStream in = urlConn.getInputStream();  
          while ( (ch = in.read()) != -1) {  
              rec.append((char)ch);  
          }  
      } ....

请提供帮助。

尝试使用以下代码下载:

private void downloadFile() throws Exception {

        URL fileUrl = new URL("https://.....");
        URLConnection urlConnection = fileUrl.openConnection();
        BufferedInputStream bufferedInputStream = new BufferedInputStream(urlConnection.getInputStream());

        FileOutputStream fos = new FileOutputStream("c:/file.avi");
        BufferedOutputStream dest = new BufferedOutputStream(fos);

        int count;
        byte data[] = new byte[2048];
        while((count = bufferedInputStream.read(data)) != -1) {
            dest.write(data, 0, count);
        }

        dest.flush();
        dest.close();
    }

我无法从Https url下载超过150MB的文件。为什么不能?它会爆炸吗?请确切地告诉我们问题是什么。有时下载0字节的文件,有时在大文件的情况下什么也不会发生。您有任何异常吗?没有,我没有收到任何异常。您好,我使用了上面的BufferedInputStream代码,现在文件正在下载,但文件大小为0字节。我现在该怎么办??