I'd like to copy the file from Java to another directory.
boolean success = false;
File[] reviews = dir.listFiles();
String trainingDir = dir.getAbsolutePath() + "/trainingData";
File trDir = new File(trainingDir);
success = trDir.mkdir();
for(int i = 1; i <= 20; i++) {
File review = reviews[i];
}
There are about 20 files like this, and I want to move them all to a different directory. How shall I do it?
copy directory file java
Use the Apache common library FileUtils
File source = new File("H:\\work-temp\\file");
File dest = new File("H:\\work-temp\\file2");
try {
FileUtils.copyDirectory(source, dest);
} } catch (IOException e) {
e.printStackTrace();
}
Try it this way.
© 2024 OneMinuteCode. All rights reserved.