티스토리 뷰
728x90
public static List<File> files(String dirname) {
if (dirname == null) {
return Collections.emptyList();
}
File dir = new File(dirname);
if (!dir.exists()) {
return Collections.emptyList();
}
if (!dir.isDirectory()) {
return Collections.singletonList(file(dirname));
}
return Arrays.stream(Objects.requireNonNull(dir.listFiles()))
.collect(Collectors.toList());
}
How to read all files in a folder from Java?
How to read all the files in a folder through Java?
stackoverflow.com
728x90
'공부' 카테고리의 다른 글
[Java] resource (0) | 2022.01.10 |
---|---|
[Java] Orc File (0) | 2022.01.10 |
[Java] files (0) | 2022.01.10 |
[JUnit] Assert API (0) | 2022.01.10 |
[Java] type: a.getClass().getName() (0) | 2022.01.10 |
[MySQL] CREATE USER IF NOT EXISTS 'user'@'localhost' IDENTIFIED BY 'password'; (0) | 2022.01.10 |
댓글