목록폴더 삭제 (1)
삶 가운데 남긴 기록 AACII.TISTORY.COM
JAVA 특정 폴더와 하위 폴더 및 하위 파일들을 모두 삭제
이번에는 재귀 호출을 이용하여 특정 폴더의 내용을 모두 삭제하는 예제를 구현해봤습니다. import java.io.File; public class DeleteDirectoryExample { public static void main(String[] args) { String directoryPath = "C:/Temp"; // 윈도우 실행 기준 File directory = new File(directoryPath); // 디렉토리가 존재하면 삭제 수행 if (directory.exists()) { deleteDirectory(directory); System.out.println("디렉토리 및 하위 경로가 삭제되었습니다."); } else { System.out.println("디렉토리가 존재하지 ..
DEV&OPS/Java
2024. 1. 3. 20:56