Giriş
Şu satırı dahil ederiz.
Elimizde şöyle bir dizin yapısı olsun.
Şu satırı dahil ederiz.
import org.springframework.core.io.Resource;
import org.springframework.core.io.support.ResourceUtils;Elimizde şöyle bir dizin yapısı olsun.
+ resources
  + elcordelaciutat
    - FileA.txt
    - FileB.txt
    + a-dir
      - c.txt
      + c-dir
        - d.txt
    + b-dir
      - b.txtprivate ResourceLoader loader;
private List<String> getFiles() throws IOException {
  Resource[] resources = ResourcePatternUtils
    .getResourcePatternResolver(loader)
    .getResources("classpath*:elcordelaciutat/*.txt");
  return Arrays.stream(resources)
    .map(p -> p.getFilename().toUpperCase())
    .sorted()
    .collect(toList());
} 
Hiç yorum yok:
Yorum Gönder