I want to read a directory and create the same file and sub directories in another directory.
The path for the directory will be a user defined value.
private static void readFiles(File sourceFolder, String destePath) {
if (sourceFolder.isDirectory())
for (File sourceFile : sourceFolder.listFiles()) {
if (sourceFile.isFile()) {
File destFile = new File(destePath + "/"
+ sourceFile.getName());
updateConnectorXML(sourceFile, destFile);
} else {
{
destePath = destePath + "/" + sourceFile.getName();
File destFile = new File(destePath);
destFile.mkdir();
readFiles(sourceFile, destePath);
}
}
}
}
here e.d sourceFile will be "c:/abc" which is a directory and I am reading files and sub directories of sourceFile. Now in updateConnectorXML(sourceFile, destFile)
I am just updating XML files.
Now I want to create same directory structure in another folder with updated XML files.
In above code the destePath
is changed to only one directory and all files are going into the directory. How can I get back from that directory?