I want to copy file from one package to another package.
I tried Files.copy method but it replaces my folder with copied file.
public static void main(String[] args) throws IOException {
    InputStream in = CopyFileToDirectoryTest.class.getClassLoader()
            .getResourceAsStream("com/stackoverflow/main/Movie.class");
    Path path = Paths.get("D://folder");
    long copy = Files.copy(in, path,StandardCopyOption.REPLACE_EXISTING);
    System.out.println(copy);
}
This doesn't work because it deletes folder and creates file with the name of folder.
Is there a way in Java 8 or I should use Apache Commons IO?
 
     
    