code: @Override
      public DownloadFile download(URL url) throws IOException {
          if (url == null) {
              throw new InvalidArgument("url", url);
          }
  
          final HttpURLConnection huc = (HttpURLConnection) url.openConnection();
          FileOutputStream fos = null;
          try {
              huc.setConnectTimeout(CONNECTION_TIMEOUT);
              huc.setInstanceFollowRedirects(true);
  
              final int code = huc.getResponseCode();
              if (code != HttpURLConnection.HTTP_OK) {
                  throw new IOException(format("Bad response code: %d", code));
              }
  
              final String downloadDir = asPath(
                      getSystemConfiguration().getWorkingDirectory()
                              .getAbsolutePath(),
                      DOWNLOAD_DIRECTORY);
              createDirectory(downloadDir);
  
              final String filename = UUID.randomUUID().toString();
              String downloadFile = asPath(downloadDir, filename);
              fos = new FileOutputStream(downloadFile);
              copy(huc.getInputStream(), fos);
  
              // attempt to download checksum
              String checksum = null;
              final String checksumLocation = url.toString() + SHA256_EXTENSION;
              HttpURLConnection chksum = null;
              BufferedReader br = null;
              try {
                  URL checksumUrl = new URL(checksumLocation);
                  chksum = (HttpURLConnection) checksumUrl.openConnection();
                  chksum.setConnectTimeout(CONNECTION_TIMEOUT);
                  chksum.setInstanceFollowRedirects(true);
  
                  br = new BufferedReader(new InputStreamReader(
                          chksum.getInputStream()));
                  checksum = br.readLine();
              } catch (IOException e) {
                  // checksum is optional, so do not propogate exception
              } finally {
                  closeQuietly(br);
              }
  
              return new DownloadFile(new File(downloadFile), checksum);
          } finally {
              if (huc != null) {
                  closeQuietly(huc.getInputStream());
              }
              closeQuietly(fos);
          }
      }
docs: {@inheritDoc}