한 위치에서 디렉토리를 복사 할 수 있습니다에 srcFolder
의 전체 내용을 복사하는 코드가 필요합니다 : 나는이 또한
public static void copyDirectoryOneLocationToAnotherLocation(File sourceLocation, File targetLocation)
throws IOException {
if (sourceLocation.isDirectory()) {
if (!targetLocation.exists()) {
targetLocation.mkdir();
}
String[] children = sourceLocation.list();
for (int i = 0; i < sourceLocation.listFiles().length; i++) {
copyDirectoryOneLocationToAnotherLocation(new File(sourceLocation, children[i]),
new File(targetLocation, children[i]));
}
} else {
InputStream in = new FileInputStream(sourceLocation);
OutputStream out = new FileOutputStream(targetLocation);
// Copy the bits from instream to outstream
byte[] buf = new byte[1024];
int len;
while ((len = in.read(buf)) > 0) {
out.write(buf, 0, len);
}
in.close();
out.close();
}
}
이 링크를 클릭하면 한 폴더에서 다른 폴더로 파일을 복사하거나 이동할 수 있습니다. http://www.codeofaninja.com/2013/04/copy-or-move-file-from-one-directory-to.html
모든 파일을 반복적으로 순환하여 파일을 복사하는 것입니다 (또는 파일이 아닌 폴더 인 경우 더 깊게 이동하는 것). –