diff --git a/core-java-modules/core-java-io-2/src/main/java/com/baeldung/listfiles/ListFiles.java b/core-java-modules/core-java-io-2/src/main/java/com/baeldung/listfiles/ListFiles.java index 2275128dfe..c108d9ed96 100644 --- a/core-java-modules/core-java-io-2/src/main/java/com/baeldung/listfiles/ListFiles.java +++ b/core-java-modules/core-java-io-2/src/main/java/com/baeldung/listfiles/ListFiles.java @@ -24,9 +24,20 @@ public class ListFiles { .collect(Collectors.toSet()); } + public Set listFilesUsingFilesList(String dir) throws IOException { + try (Stream stream = Files.list(Paths.get(dir))) { + return stream + .filter(file -> !Files.isDirectory(file)) + .map(Path::getFileName) + .map(Path::toString) + .collect(Collectors.toSet()); + } + } + public Set listFilesUsingFileWalk(String dir, int depth) throws IOException { try (Stream stream = Files.walk(Paths.get(dir), depth)) { - return stream.filter(file -> !Files.isDirectory(file)) + return stream + .filter(file -> !Files.isDirectory(file)) .map(Path::getFileName) .map(Path::toString) .collect(Collectors.toSet()); diff --git a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/listfiles/ListFilesUnitTest.java b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/listfiles/ListFilesUnitTest.java index a87097f085..5b4efc9e58 100644 --- a/core-java-modules/core-java-io-2/src/test/java/com/baeldung/listfiles/ListFilesUnitTest.java +++ b/core-java-modules/core-java-io-2/src/test/java/com/baeldung/listfiles/ListFilesUnitTest.java @@ -25,10 +25,15 @@ public class ListFilesUnitTest { }; @Test - public void givenDir_whenUsingJAVAIO_thenListAllFiles() throws IOException { + public void givenDir_whenUsingJAVAIO_thenListAllFiles() { assertEquals(EXPECTED_FILE_LIST, listFiles.listFilesUsingJavaIO(DIRECTORY)); } + @Test + public void givenDir_whenUsingFilesList_thenListAllFiles() throws IOException { + assertEquals(EXPECTED_FILE_LIST, listFiles.listFilesUsingFilesList(DIRECTORY)); + } + @Test public void givenDir_whenWalkingTree_thenListAllFiles() throws IOException { assertEquals(EXPECTED_FILE_LIST, listFiles.listFilesUsingFileWalk(DIRECTORY,DEPTH)); diff --git a/pom.xml b/pom.xml index 79bf7d72b7..5e00377a6b 100644 --- a/pom.xml +++ b/pom.xml @@ -665,7 +665,6 @@ spring-mvc-velocity spring-mvc-views - spring-mvc-webflow spring-mvc-xml spring-protobuf @@ -1133,7 +1132,6 @@ spring-mvc-velocity spring-mvc-views - spring-mvc-webflow spring-mvc-xml spring-protobuf diff --git a/spring-web-modules/pom.xml b/spring-web-modules/pom.xml index ce0524f957..5f24f45a8f 100644 --- a/spring-web-modules/pom.xml +++ b/spring-web-modules/pom.xml @@ -20,6 +20,7 @@ spring-mvc-basics-4 spring-mvc-crash spring-mvc-forms-jsp + spring-mvc-webflow spring-rest-angular spring-rest-http spring-resttemplate-2 diff --git a/spring-mvc-webflow/README.md b/spring-web-modules/spring-mvc-webflow/README.md similarity index 100% rename from spring-mvc-webflow/README.md rename to spring-web-modules/spring-mvc-webflow/README.md diff --git a/spring-mvc-webflow/pom.xml b/spring-web-modules/spring-mvc-webflow/pom.xml similarity index 100% rename from spring-mvc-webflow/pom.xml rename to spring-web-modules/spring-mvc-webflow/pom.xml diff --git a/spring-mvc-webflow/src/main/java/org/baeldung/servlet/WebInitializer.java b/spring-web-modules/spring-mvc-webflow/src/main/java/org/baeldung/servlet/WebInitializer.java similarity index 100% rename from spring-mvc-webflow/src/main/java/org/baeldung/servlet/WebInitializer.java rename to spring-web-modules/spring-mvc-webflow/src/main/java/org/baeldung/servlet/WebInitializer.java diff --git a/spring-mvc-webflow/src/main/java/org/baeldung/spring/WebFlowConfig.java b/spring-web-modules/spring-mvc-webflow/src/main/java/org/baeldung/spring/WebFlowConfig.java similarity index 100% rename from spring-mvc-webflow/src/main/java/org/baeldung/spring/WebFlowConfig.java rename to spring-web-modules/spring-mvc-webflow/src/main/java/org/baeldung/spring/WebFlowConfig.java diff --git a/spring-mvc-webflow/src/main/java/org/baeldung/spring/WebMvcConfig.java b/spring-web-modules/spring-mvc-webflow/src/main/java/org/baeldung/spring/WebMvcConfig.java similarity index 100% rename from spring-mvc-webflow/src/main/java/org/baeldung/spring/WebMvcConfig.java rename to spring-web-modules/spring-mvc-webflow/src/main/java/org/baeldung/spring/WebMvcConfig.java diff --git a/spring-mvc-webflow/src/main/resources/flow-definition.xml b/spring-web-modules/spring-mvc-webflow/src/main/resources/flow-definition.xml similarity index 100% rename from spring-mvc-webflow/src/main/resources/flow-definition.xml rename to spring-web-modules/spring-mvc-webflow/src/main/resources/flow-definition.xml diff --git a/spring-mvc-webflow/src/main/resources/logback.xml b/spring-web-modules/spring-mvc-webflow/src/main/resources/logback.xml similarity index 100% rename from spring-mvc-webflow/src/main/resources/logback.xml rename to spring-web-modules/spring-mvc-webflow/src/main/resources/logback.xml diff --git a/spring-mvc-webflow/src/main/webapp/WEB-INF/flows/activation-flow.xml b/spring-web-modules/spring-mvc-webflow/src/main/webapp/WEB-INF/flows/activation-flow.xml similarity index 100% rename from spring-mvc-webflow/src/main/webapp/WEB-INF/flows/activation-flow.xml rename to spring-web-modules/spring-mvc-webflow/src/main/webapp/WEB-INF/flows/activation-flow.xml diff --git a/spring-mvc-webflow/src/main/webapp/WEB-INF/view/activation.jsp b/spring-web-modules/spring-mvc-webflow/src/main/webapp/WEB-INF/view/activation.jsp similarity index 100% rename from spring-mvc-webflow/src/main/webapp/WEB-INF/view/activation.jsp rename to spring-web-modules/spring-mvc-webflow/src/main/webapp/WEB-INF/view/activation.jsp diff --git a/spring-mvc-webflow/src/main/webapp/WEB-INF/view/failure.jsp b/spring-web-modules/spring-mvc-webflow/src/main/webapp/WEB-INF/view/failure.jsp similarity index 100% rename from spring-mvc-webflow/src/main/webapp/WEB-INF/view/failure.jsp rename to spring-web-modules/spring-mvc-webflow/src/main/webapp/WEB-INF/view/failure.jsp diff --git a/spring-mvc-webflow/src/main/webapp/WEB-INF/view/sample.jsp b/spring-web-modules/spring-mvc-webflow/src/main/webapp/WEB-INF/view/sample.jsp similarity index 100% rename from spring-mvc-webflow/src/main/webapp/WEB-INF/view/sample.jsp rename to spring-web-modules/spring-mvc-webflow/src/main/webapp/WEB-INF/view/sample.jsp diff --git a/spring-mvc-webflow/src/main/webapp/WEB-INF/view/success.jsp b/spring-web-modules/spring-mvc-webflow/src/main/webapp/WEB-INF/view/success.jsp similarity index 100% rename from spring-mvc-webflow/src/main/webapp/WEB-INF/view/success.jsp rename to spring-web-modules/spring-mvc-webflow/src/main/webapp/WEB-INF/view/success.jsp diff --git a/spring-mvc-webflow/src/test/java/org/baeldung/SpringContextTest.java b/spring-web-modules/spring-mvc-webflow/src/test/java/org/baeldung/SpringContextTest.java similarity index 100% rename from spring-mvc-webflow/src/test/java/org/baeldung/SpringContextTest.java rename to spring-web-modules/spring-mvc-webflow/src/test/java/org/baeldung/SpringContextTest.java