Java
[Java] 자료실 구현 : 서버에 업로드된 파일 삭제
펜네임
2020. 4. 2. 17:27
Controller
//-- 조회조건 ------------------------------
JSONObject json = CommonUtils.readJSONObjectFromRequest(request);
// 삭제할 파일정보 조회
List<EgovMap> delList = fileService.selectDelList(json);
// 서버파일 삭제
for (int i=0; i<delList.size(); i++) {
String fileAddr = "파일주소";
File file = new File(fileAddr);
Boolean chk = file.delete();
// 서버파일 삭제 실패 시
if (!chk) {
break;
}
}