title: java.io.IOException: An existing connection was forcibly closed by the remote host when trying to download file
body: <p>I'm trying to download a file using Java from a <code>https://</code> url and it keeps returning me this error:</p>
  
  <blockquote>
    <p>java.io.IOException: An existing connection was forcibly closed by the
    remote host</p>
  </blockquote>
  
  <p>Here is the code I am using:</p>
  
  <pre><code>URL website = new URL(fileUrl);
  File destinationFile = new File(toPath + returnFileNameFromUrl(fileUrl));
  FileUtils.copyURLToFile(website, destinationFile);
  </code></pre>
  
  <p>I already tried doing like this:</p>
  
  <pre><code>try (InputStream inputStream = website.openStream();
       ReadableByteChannel rbc = Channels.newChannel(inputStream);
       FileOutputStream fileOutputStream = new FileOutputStream(toPath + returnFileNameFromUrl(fileUrl))) {
       fileOutputStream.getChannel().transferFrom(rbc, 0, Long.MAX_VALUE);
       }
  </code></pre>
  
  <p>But the result was the same.
  What am I doing wrong?</p>
  
  <p>I already checked, the URL is accesible from Chrome and the file exists.</p>