code: public static void sendFileToHttpServiceResponse(File file, HttpServletResponse res, String contentType) {
  
          if (file == null || res == null) {
              return;
          }
          String filename = getEncodingFileName(file.getName());
          initFileSendHeader(res, filename, contentType);
  
          res.setContentLength((int) file.length());
          try {
              res.getOutputStream().write(Files.readAllBytes(file.toPath()));
          } catch (IOException e) {
              throw new ValidationLibException("file io error :" + e.getMessage());
          }
      }
docs: Send file to http service response.
  
  @param file        the file
  @param res         the res
  @param contentType the content type