code: private void truncateDestinationFileIfNecessary() {
          RandomAccessFile raf = null;
          if (!FileLocks.lock(dstfile)) {
              throw new FileLockException("Fail to lock " + dstfile);
          }
  
          try {
              raf = new RandomAccessFile(dstfile, "rw");
              if (lastFullyMergedPartNumber == 0) {
                  raf.setLength(0);
              } else {
                  long lastByte = ServiceUtils.getLastByteInPart(s3, req, lastFullyMergedPartNumber);
                  if (dstfile.length() < lastByte) {
                      throw new SdkClientException(
                          "File " + dstfile.getAbsolutePath() + " has been modified since last pause.");
                  }
                  raf.setLength(lastByte + 1);
                  download.getProgress().updateProgress(lastByte + 1);
              }
          } catch (Exception e) {
              throw new SdkClientException("Unable to append part file to dstfile " + e.getMessage(), e);
          } finally {
              IOUtils.closeQuietly(raf, LOG);
              FileLocks.unlock(dstfile);
          }
      }
docs: If only partial part object is merged into the dstFile(due to pause
  operation), adjust the file length so that the part starts writing from
  the correct position.