I am working on a java project that needs to copy a directory which contains directories of images. Since I'm new to Java, I designed the below code myself to copy the directory. But I get a 'null pointer exception' error. Can someone help me correct my script? Or give me some suggestions?
public CopyDir() throws IOException {
String destFolder1 = System.getProperty("user.home")+"/desktop/pics";
File srcFolder = new File("C:\\rkm_vidyapith\\pics");
if (!Files.exists(Paths.get(destFolder1),null))
new File(destFolder1).mkdirs();
if (srcFolder.isDirectory()) {
for (String DirList : srcFolder.list()) {
File FileList = new File(DirList);
for (String EachFile:FileList.list())
Files.copy(Paths.get(EachFile),
Paths.get(destFolder1),
StandardCopyOption.REPLACE_EXISTING);
}
}
}