public byte[] download(String generatePath, String fileName, SkeletonProperties skeletonProperties) { if (StringUtils.isEmpty(generatePath)) { generatePath = SkeletonUtil.getTempGeneratePath(); } if (StringUtils.isEmpty(fileName)) { throw new SkeletonException("File name is null or empty"); } try { String canonicalPath = SkeletonUtil.getCanonicalPath(generatePath, fileName, skeletonProperties); generate(canonicalPath, skeletonProperties); String zipFilePath = ZipUtil.zip(canonicalPath, null); File zipFile = new File(zipFilePath); LOG.info("Download skeleton file for " + zipFile.getName() + " is executed"); return FileUtil.getBytes(zipFile); } catch (Exception e) { throw new SkeletonException(e.getMessage(), e); } finally { File directory = new File(generatePath); FileUtil.forceDeleteDirectory(directory, 5); } }