파일 경로에 있는 폴더에 있는 전체 파일을 갖고 와서 단순하게 파일 이름을 출력하는 알고리즘입니다.
String fileName = ""; /*파일 경로에 있는 파일 가져오기*/ File rw = new File(filePath); /*파일 경로에 있는 파일 리스트 fileList[] 에 넣기*/ File []fileList = rw.listfiles(); /*fileList에 있는거 for 문 돌려서 출력*/ for(File file : fileList) { if(file.isFile()) { fileName = file.getName(); System.out.println("fileName : " + fileName); } }
728x90
반응형
'Back-end > JAVA & Spring' 카테고리의 다른 글
[Java] 영상에서 썸네일(Thumbnail) 추출하기 (0) | 2021.11.23 |
---|---|
[JAVA] image resize & crop (Thumbnail) (0) | 2021.11.23 |
[JAVA] JSONObject key 값이 null 일때 해결 방법 (0) | 2021.11.15 |
[Spring] Controller에서 데이터 받기 (0) | 2021.10.21 |
[문제해결] Several ports (8005, 8080, 8009) required by Tomcat v7.0 Server at localhost are already in use. (0) | 2021.10.05 |
댓글