예는 다음과 같습니다.
public static void copyfolder (String srcfolder, String Destfolder)는 ioexception {long starttime = system.currenttimeMillis (); 최종 경로 srcpath = paths.get (srcfolder); // 쉘 최종 경로의 문제를 해결하기 위해 여기서 하나 더 레벨을 만듭니다. destPath = paths.get (destfolder, srcpath.tofile (). getName ()); // if (files.notexists (srcpath)) {system.err.println ( "소스 폴더가 존재하지 않는다"); System.exit (1); } // 대상 디렉토리가 존재하지 않으면 if (files.notexists (destpath)) {files.createdirectories (destpath); } // 여기에는 공식 예제의 시작이 있습니다.이 예제는 큰 파일 처리 // files.walkfiletree (srcpath, enumset.of (filevisitoPtion.follow_links), // integer.max_value, new SimpleFilevisitor <path> () {} // sumplified walkfiletree (srcpute)에 대한 매개 변수 세트 일 수 있습니다. SimpleFileVisitor <path> () {// 공무원은 여기에 사용되지 않는 특수 폴더 처리라고도합니다. attres) {path dest path = System.CurrentTimeMillis (); " + (endtime -starttime) +"ms "); ENDECT! ");} files.walkFileTree (시작, 새로운 SimpleFileVisitor <TATH> () {@OVERRIDE // 파일 처리 파일 공개 fileVisitresult visitFile (Path File, BasicFileAttributes Attrs)은 ioexception {files.delete (파일); 그런 다음 publestinue} @override // return procation; postvisitDirectory (path exception e)는 {e == null (dir) {else}; {// copyfolder ( "c : // users // inductor // desktop // 111", "d : // compression // level 2"); // 419ms, 378ms, 429ms .... deletefolder ( "c : // users // inductator // goodtop // 111");}궁금한 점이 있으면 문의하십시오. 감사합니다!
JDK1.7 경로 및 파일 클래스에서 폴더의 복사 및 삭제의 위의 예는 편집기가 공유하는 전체 컨텐츠입니다. 나는 그것이 당신에게 참조를 줄 수 있기를 바랍니다. 그리고 당신이 wulin.com을 더 지원할 수 있기를 바랍니다.