[JAVA] 특정 폴더에 있는 파일 읽기

[JAVA] 특정 폴더에 있는 파일 읽기

728x90

파일 경로에 있는 폴더에 있는 전체 파일을 갖고 와서 단순하게 파일 이름을 출력하는 알고리즘입니다.

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

from http://byul91oh.tistory.com/408 by ccl(A) rewrite - 2021-11-19 16:27:56