讀取特定資料夾下的xls檔

URL Link //n.sfs.tw/13053

2019-01-25 10:18:24 By igogo

 

讀取特定資料夾下的xls檔


 String docPath = String.format("%s/docs", System.getProperty("user.dir"));

        List<Path> xlsPaths = new ArrayList<>();
        try (Stream<Path> paths = Files.walk(Paths.get(docPath))) {
            paths.filter(Files::isRegularFile)
                    .filter(p -> p.toString().endsWith(".xls"))
                    .forEach(xlsPaths::add);
        }

        xlsPaths.forEach(xls -> System.out.println(xls.toString()));

 

https://stackoverflow.com/questions/1844688/how-to-read-all-files-in-a-folder-from-java

https://stackoverflow.com/questions/29574167/how-to-use-files-walk-to-get-a-graph-of-files-based-on-conditions