I've been facing an issues while copying the zip file(contains couple of RPM files) from resource folder to target folder using Spring boot application. It does create the zip file on target folder path but it doesn't have all the files inside and the one's created are corrupted. Please see attachment
I had gone through couple of links but seems solution is not working perfectly
- How to get files from resources folder. Spring Framework
- Read file from resources folder in Spring Boot
Snapshot of Resource zip Folder
[
Snapshot of files inside zip Folder
Code:
ClassPathResource cpr = null;
cpr = new ClassPathResource("/16.00/package.zip");
try {
InputStream data = cpr.getInputStream();
File targetFile = new File("C:\\package.zip");
java.nio.file.Files.copy(
data,
targetFile.toPath(),
StandardCopyOption.REPLACE_EXISTING);
IOUtils.closeQuietly(data);
log.info("w"+data);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
The above code create a zip file on target folder but its corrupted.When i try to open the file it gives me following error