mkdir : 하위 디렉터리 생성 불가
mkdirs : 하위 디렉터리 생성 가능
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | f_list = new File(source).listFiles(); // 폴더들 위치 System.out.println( "총 " + f_list.length + " 개의 폴더가 존재합니다. " ); for ( int folder = 0 ; folder < f_list.length ; folder++){ System.out.println(folder + " 번째 디렉토리를 분석중입니다." ); // 디렉토리 명을 수정 ( / 기호가 안붙을 경우를 위함) String chk = destination.substring(destination.length()- 1 , destination.length()); if (!chk.equals( "/" ))destination = destination+ "/" ; // 생성할 디렉토리 명을 지정 String mkFolder = destination+f_list[folder].getName(); //하나의 폴더 File[] fileList = f_list[folder].listFiles(); // 파일들 //디렉토리 생성 File desti = new File(mkFolder); //해당 디렉토리의 존재여부를 확인 if (!desti.exists()){ //없다면 생성 desti.mkdirs(); } else { //있다면 현재 디렉토리 파일을 삭제 File[] destroy = desti.listFiles(); for (File des : destroy){ des.delete(); } } System.out.println( "디렉토리 명 = " + mkFolder); for ( int f = 0 ; f < fileList.length ; f++){ System.out.println( "\t" + f + " 번째 파일 분석 중..." ); |