Skip to content
Advertisement

Java : How to copy folder with contents from resource and copy to temp directory?

Project structure:

JavaScript

Using maven-assembly plugin, I am including the resources in the jar file.

As PMD folder will be used by the applcaition, I would like to create a copy of the PMD folder in the temp directory, so that I can start reading the bat files and other files from that temp directory.

ISSUE

When the jar loads, it fails to read the PMD folder inside resource.

Tried :

JavaScript

Here it just creates the PMD folder in temp directory and nothing, inner files and folders are not copied. Any way we can achieve this?

Advertisement

Answer

Here is what I came up with.

Converted the folder to zip and put that zipped file in resources. As inputstream can only read through a file.

JavaScript

Then extracted the zip contents to the temp directory and then using that overall application.

JavaScript
User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement