From 55d36768129a31ff428fc77b230d0b011659dc7b Mon Sep 17 00:00:00 2001 From: mikr Date: Tue, 29 Dec 2020 22:56:18 +0100 Subject: [PATCH 1/2] JAVA-3530 Move spring-mvc-webflow module --- pom.xml | 2 -- spring-web-modules/pom.xml | 1 + .../spring-mvc-webflow}/README.md | 0 .../spring-mvc-webflow}/pom.xml | 0 .../src/main/java/org/baeldung/servlet/WebInitializer.java | 0 .../src/main/java/org/baeldung/spring/WebFlowConfig.java | 0 .../src/main/java/org/baeldung/spring/WebMvcConfig.java | 0 .../spring-mvc-webflow}/src/main/resources/flow-definition.xml | 0 .../spring-mvc-webflow}/src/main/resources/logback.xml | 0 .../src/main/webapp/WEB-INF/flows/activation-flow.xml | 0 .../src/main/webapp/WEB-INF/view/activation.jsp | 0 .../src/main/webapp/WEB-INF/view/failure.jsp | 0 .../spring-mvc-webflow}/src/main/webapp/WEB-INF/view/sample.jsp | 0 .../src/main/webapp/WEB-INF/view/success.jsp | 0 .../src/test/java/org/baeldung/SpringContextTest.java | 0 15 files changed, 1 insertion(+), 2 deletions(-) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/README.md (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/pom.xml (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/main/java/org/baeldung/servlet/WebInitializer.java (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/main/java/org/baeldung/spring/WebFlowConfig.java (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/main/java/org/baeldung/spring/WebMvcConfig.java (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/main/resources/flow-definition.xml (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/main/resources/logback.xml (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/main/webapp/WEB-INF/flows/activation-flow.xml (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/main/webapp/WEB-INF/view/activation.jsp (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/main/webapp/WEB-INF/view/failure.jsp (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/main/webapp/WEB-INF/view/sample.jsp (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/main/webapp/WEB-INF/view/success.jsp (100%) rename {spring-mvc-webflow => spring-web-modules/spring-mvc-webflow}/src/test/java/org/baeldung/SpringContextTest.java (100%) diff --git a/pom.xml b/pom.xml index f8e84c09e1..a0c412de9c 100644 --- a/pom.xml +++ b/pom.xml @@ -664,7 +664,6 @@ spring-mvc-velocity spring-mvc-views - spring-mvc-webflow spring-mvc-xml spring-protobuf @@ -1134,7 +1133,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 3dea8fc36e..8c426fe9c0 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-http spring-thymeleaf spring-thymeleaf-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 From 078169109d789fd0a96cc5401485117f60f120bb Mon Sep 17 00:00:00 2001 From: kwoyke Date: Wed, 30 Dec 2020 12:39:45 +0100 Subject: [PATCH 2/2] BAEL-4755: Add Files.list example (#10356) --- .../main/java/com/baeldung/listfiles/ListFiles.java | 13 ++++++++++++- .../com/baeldung/listfiles/ListFilesUnitTest.java | 7 ++++++- 2 files changed, 18 insertions(+), 2 deletions(-) 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));