I've a folder with name "test" and has many folders and files inside it. I've to copy this folder to a dynamic location in Java. Below is the code I've written:
class FileManager {
public static void copy(Path path) throws IOException {
InputStream inputStream = FileManager.class.getClassLoader().getResourceAsStream("test");
Files.copy(inputStream, path, StandardCopyOption.REPLACE_EXISTING);
}
}
This is copying to the location but not copying as a folder, but as a file. The path string I'm sending is "C:/Users/test". Most importantly I want this code working in jar. I cannot get the physical location of the "test" folder in the jar.