From d797620785a5e0a21c43b08bb8fa3af9b42e2421 Mon Sep 17 00:00:00 2001
From: DankevichMisha <83833016+DankevichMisha@users.noreply.github.com>
Date: Sun, 8 Oct 2023 22:39:05 +0300
Subject: [PATCH 01/10] Add files via upload
---
jv-read-from-file1/README.md | 22 +++++
jv-read-from-file1/checklist.md | 55 +++++++++++
jv-read-from-file1/pom.xml | 67 +++++++++++++
.../main/java/core/basesyntax/FileWork.java | 19 ++++
.../java/core/basesyntax/FileWorkTest.java | 99 +++++++++++++++++++
jv-read-from-file1/test1 | 0
jv-read-from-file1/test2 | 6 ++
jv-read-from-file1/test3 | 4 +
jv-read-from-file1/test4 | 4 +
jv-read-from-file1/test5 | 4 +
10 files changed, 280 insertions(+)
create mode 100644 jv-read-from-file1/README.md
create mode 100644 jv-read-from-file1/checklist.md
create mode 100644 jv-read-from-file1/pom.xml
create mode 100644 jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
create mode 100644 jv-read-from-file1/src/test/java/core/basesyntax/FileWorkTest.java
create mode 100644 jv-read-from-file1/test1
create mode 100644 jv-read-from-file1/test2
create mode 100644 jv-read-from-file1/test3
create mode 100644 jv-read-from-file1/test4
create mode 100644 jv-read-from-file1/test5
diff --git a/jv-read-from-file1/README.md b/jv-read-from-file1/README.md
new file mode 100644
index 00000000..7bf39057
--- /dev/null
+++ b/jv-read-from-file1/README.md
@@ -0,0 +1,22 @@
+# jv-read-from-file
+You are given a file that contains different words as well as punctuation.
+
+You need to filter out only the words starting with `w`, and remove any punctuation if necessary.
+
+The result should be returned as a naturally sorted array.
+All words should be lower-case.
+
+If the file does not contain the necessary words, return an empty array.
+
+Examples:
+```
+"Width world Wide web"
+Result: ["web", "wide", "width", "world"]
+
+"WWW? Four-bedroom farmhouse in the countryside. Wave! All of the four double bedrooms are en suite."
+Result: ["wave", "www"]
+```
+
+Hint: try to split Strings with a regular expression that includes whitespace and punctuation characters.
+Here is a good [article](https://stackoverflow.com/questions/13225175/java-string-split-with-a-regex).
+#### [Try to avoid these common mistakes, while solving task](https://mate-academy.github.io/jv-program-common-mistakes/java-core/builder-file/read-from-file.html)
diff --git a/jv-read-from-file1/checklist.md b/jv-read-from-file1/checklist.md
new file mode 100644
index 00000000..baefe4f6
--- /dev/null
+++ b/jv-read-from-file1/checklist.md
@@ -0,0 +1,55 @@
+### Common mistakes
+
+#### Create variables with informative names.
+
+Bad naming:
+```java
+BufferedReader br = new BufferedReader(new FileReader(fileName))
+```
+
+Good naming:
+```java
+BufferedReader bufferedReader = new BufferedReader(new FileReader(fileName))
+```
+
+#### Use constants where applicable.
+If you have strange strings or numbers in the code it's better to declare them as constants.
+The name of the constant should display this object's purpose.
+
+Bad practice:
+```java
+ public boolean startWithLetter(String word) {
+ return word.startsWith("d"); // why do we use 'd' here???
+ }
+```
+
+Good practice:
+```java
+ private static final String SPECIFIED_CHARACTER = "d";
+
+ public boolean startWithLetter(String word) {
+ return word.startsWith(SPECIFIED_CHARACTER);
+ }
+```
+[Correct constant names](https://google.github.io/styleguide/javaguide.html#s5.2.4-constant-names)
+
+#### Close all resources.
+Connections, streams, files, and other classes that implement the `Closeable` or `AutoCloseable` interface,
+needs to be closed after use. Furthermore, that close should be done in a `finally` block.
+Preferably, when class implements `AutoCloseable`, resource should be created using "try-with-resources" pattern
+and will be closed automatically.
+
+#### Don't ignore exceptions.
+Leaving empty catch block or `e.printStackTrace` here is a bad practice.
+Better re-throw `RuntimeException` with original exception in the parameters:
+```java
+catch (Exception e) {
+ throw new RuntimeException(e);
+}
+```
+
+#### Don't create redundant variables.
+Let's make your code simple and easy to read. So better avoid using redundant variables.
+
+#### Use System.lineSeparator() insted `\n`
+[explanation](https://www.geeksforgeeks.org/system-lineseparator-method-in-java-with-examples/)
diff --git a/jv-read-from-file1/pom.xml b/jv-read-from-file1/pom.xml
new file mode 100644
index 00000000..60c679a0
--- /dev/null
+++ b/jv-read-from-file1/pom.xml
@@ -0,0 +1,67 @@
+
+
+ 4.0.0
+
+ mate-academy
+ read-from-file
+ 1.0-SNAPSHOT
+
+
+ 11
+ UTF-8
+ UTF-8
+ 3.1.1
+
+ https://raw.githubusercontent.com/mate-academy/style-guides/master/java/checkstyle.xml
+
+
+
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ 3.1.1
+
+
+ compile
+
+ check
+
+
+
+
+ ${maven.checkstyle.plugin.configLocation}
+ UTF-8
+ true
+ true
+ false
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.0
+
+
+ ${jdk.version}
+ ${project.build.sourceEncoding}
+
+
+
+
+
+
diff --git a/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java b/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
new file mode 100644
index 00000000..73d98ed3
--- /dev/null
+++ b/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
@@ -0,0 +1,19 @@
+package core.basesyntax;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileNotFoundException;
+import java.io.FileReader;
+
+public class FileWork {
+ public String[] readFromFile(String fileName) throws FileNotFoundException {
+ File m = new File("test1");
+ File my = new File("test2");
+ File myf = new File("test3");
+ File myfi = new File("test4");
+ File myfil = new File("test5");
+ FileReader fileReader = new FileReader(m);
+ BufferedReader bufferedReader = new BufferedReader(fileReader);
+
+ }
+}
diff --git a/jv-read-from-file1/src/test/java/core/basesyntax/FileWorkTest.java b/jv-read-from-file1/src/test/java/core/basesyntax/FileWorkTest.java
new file mode 100644
index 00000000..2e2f9393
--- /dev/null
+++ b/jv-read-from-file1/src/test/java/core/basesyntax/FileWorkTest.java
@@ -0,0 +1,99 @@
+package core.basesyntax;
+
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class FileWorkTest {
+ private static final String TEMP_DIRECTORY = System.getProperty("java.io.tmpdir") + "/";
+ private static final String EMPTY_FILE_NAME = TEMP_DIRECTORY + "test1";
+ private static final String SECOND_FILE_NAME = TEMP_DIRECTORY + "test2";
+ private static final String THIRD_FILE_NAME = TEMP_DIRECTORY + "test3";
+ private static final String FOURS_FILE_NAME = TEMP_DIRECTORY + "test4";
+ private static final String FIFTH_FILE_NAME = TEMP_DIRECTORY + "test5";
+
+ private static final String[] EMPTY_ARRAY_RESULT = new String[0];
+ private static final String[] RESULT_FROM_LOWER_CASE =
+ new String[]{"walk", "warm", "with", "with"};
+ private static final String[] RESULT_FROM_CAMEL_CASE =
+ new String[]{"wall", "wave", "width", "world", "www"};
+ private static final String[] RESULT_FROM_ADJACENT_WORDS_CASE =
+ new String[]{"was", "was", "whenever", "which", "which", "worse"};
+
+ @BeforeClass
+ public static void beforeClass() throws Exception{
+ Files.write(Path.of(EMPTY_FILE_NAME), "".getBytes(StandardCharsets.UTF_8));
+ Files.write(Path.of(SECOND_FILE_NAME), (
+ "Beautiful two-bedroom city flat five minutes' walk from the cathedral.\n" +
+ "Fully equipped kitchen, living room with a large sofa and chairs, big TV and balcony.\n" +
+ "The balcony has space for four people to sit and gets the sun in the mornings,\n" +
+ "and the flat is light and warm. The upstairs bedroom sleeps four people, with two double beds;\n" +
+ "the downstairs bedroom sleeps two in single beds.\n" +
+ "The flat is perfect for families and is near shops, bars and restaurants.\n").getBytes(StandardCharsets.UTF_8));
+ Files.write(Path.of(THIRD_FILE_NAME), (
+ "Four-bedroom farmhouse in the countryside. All of the four double bedrooms are en suite.\n" +
+ "Farm kitchen, tables and chairs outside. Great for groups of friends. The supermarket is half\n" +
+ "an hour by car and you can take a train from the village into the city. Escape from normal life\n" +
+ "for a few days.\n").getBytes(StandardCharsets.UTF_8));
+ Files.write(Path.of(FOURS_FILE_NAME), (
+ "WWW? Four-bedroom farmhouse in the countryside. Wave! All of the four double bedrooms are en suite.\n" +
+ "Farm kitchen, tables and chairs outside. Great for groups of friends. World and the supermarket is\n" +
+ "half an hour by car and you can take a train from wall the village into the city. Escape from normal\n" +
+ "life for a few days, width.\n").getBytes(StandardCharsets.UTF_8));
+ Files.write(Path.of(FIFTH_FILE_NAME), (
+ "Whenever I have gone there, there have been either so many\n" +
+ "people that I have not been able to see the pictures, which\n" +
+ "was dreadful, or so many pictures that I have not been able to see the people, which was\n" +
+ "worse. The Grosvenor is really the only place.\"\n").getBytes(StandardCharsets.UTF_8));
+ }
+
+ @Test
+ public void readFromEmptyFile() {
+ FileWork fileWork = new FileWork();
+ String[] actualResult = fileWork.readFromFile(EMPTY_FILE_NAME);
+ Assert.assertArrayEquals("Test failed! You should returned empty array.",
+ EMPTY_ARRAY_RESULT, actualResult);
+ }
+
+ @Test
+ public void getLowerCaseResultFromFile() {
+ FileWork fileWork = new FileWork();
+ String[] actualResult = fileWork.readFromFile(SECOND_FILE_NAME);
+ Assert.assertArrayEquals("Test failed! You should returned next array "
+ + Arrays.toString(RESULT_FROM_LOWER_CASE) + " but you returned "
+ + Arrays.toString(actualResult),
+ RESULT_FROM_LOWER_CASE, actualResult);
+ }
+
+ @Test
+ public void getCamelCaseResultFromFile() {
+ FileWork fileWork = new FileWork();
+ String[] actualResult = fileWork.readFromFile(FOURS_FILE_NAME);
+ Assert.assertArrayEquals("Test failed! You should returned next array "
+ + Arrays.toString(RESULT_FROM_CAMEL_CASE) + " but you returned "
+ + Arrays.toString(actualResult),
+ RESULT_FROM_CAMEL_CASE, actualResult);
+ }
+
+ @Test
+ public void getEmptyResultFromFile() {
+ FileWork fileWork = new FileWork();
+ String[] actualResult = fileWork.readFromFile(THIRD_FILE_NAME);
+ Assert.assertArrayEquals("Test failed! You should returned empty array.",
+ EMPTY_ARRAY_RESULT, actualResult);
+ }
+
+ @Test
+ public void getAdjacentWordsResultFromFile() {
+ FileWork fileWork = new FileWork();
+ String[] actualResult = fileWork.readFromFile(FIFTH_FILE_NAME);
+ Assert.assertArrayEquals("Test failed! You should returned next array "
+ + Arrays.toString(RESULT_FROM_ADJACENT_WORDS_CASE) + " but you returned "
+ + Arrays.toString(actualResult),
+ RESULT_FROM_ADJACENT_WORDS_CASE, actualResult);
+ }
+}
diff --git a/jv-read-from-file1/test1 b/jv-read-from-file1/test1
new file mode 100644
index 00000000..e69de29b
diff --git a/jv-read-from-file1/test2 b/jv-read-from-file1/test2
new file mode 100644
index 00000000..62ecaf9c
--- /dev/null
+++ b/jv-read-from-file1/test2
@@ -0,0 +1,6 @@
+Beautiful two-bedroom city flat five minutes' walk from the cathedral.
+Fully equipped kitchen, living room with a large sofa and chairs, big TV and balcony.
+The balcony has space for four people to sit and gets the sun in the mornings,
+and the flat is light and warm. The upstairs bedroom sleeps four people, with two double beds;
+the downstairs bedroom sleeps two in single beds.
+The flat is perfect for families and is near shops, bars and restaurants.
diff --git a/jv-read-from-file1/test3 b/jv-read-from-file1/test3
new file mode 100644
index 00000000..12c3961f
--- /dev/null
+++ b/jv-read-from-file1/test3
@@ -0,0 +1,4 @@
+Four-bedroom farmhouse in the countryside. All of the four double bedrooms are en suite.
+Farm kitchen, tables and chairs outside. Great for groups of friends. The supermarket is half
+an hour by car and you can take a train from the village into the city. Escape from normal life
+for a few days.
diff --git a/jv-read-from-file1/test4 b/jv-read-from-file1/test4
new file mode 100644
index 00000000..a5c34f4e
--- /dev/null
+++ b/jv-read-from-file1/test4
@@ -0,0 +1,4 @@
+WWW? Four-bedroom farmhouse in the countryside. Wave! All of the four double bedrooms are en suite.
+Farm kitchen, tables and chairs outside. Great for groups of friends. World and the supermarket is
+half an hour by car and you can take a train from wall the village into the city. Escape from normal
+life for a few days, width.
diff --git a/jv-read-from-file1/test5 b/jv-read-from-file1/test5
new file mode 100644
index 00000000..90465912
--- /dev/null
+++ b/jv-read-from-file1/test5
@@ -0,0 +1,4 @@
+Whenever I have gone there, there have been either so many
+people that I have not been able to see the pictures, which
+was dreadful, or so many pictures that I have not been able to see the people, which was
+worse. The Grosvenor is really the only place."
From a363a8c5c38ac7f73e23ac93ae81288e0c2d87d7 Mon Sep 17 00:00:00 2001
From: DankevichMisha <83833016+DankevichMisha@users.noreply.github.com>
Date: Mon, 9 Oct 2023 09:56:51 +0300
Subject: [PATCH 02/10] Add files via upload
---
.../main/java/core/basesyntax/FileWork.java | 41 +++++++++++--------
1 file changed, 25 insertions(+), 16 deletions(-)
diff --git a/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java b/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
index 73d98ed3..7188e823 100644
--- a/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
+++ b/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
@@ -1,19 +1,28 @@
package core.basesyntax;
-
-import java.io.BufferedReader;
-import java.io.File;
-import java.io.FileNotFoundException;
-import java.io.FileReader;
-
+import java.io.BufferedReader;import java.io.FileReader;
+import java.io.IOException;import java.util.Arrays;
public class FileWork {
- public String[] readFromFile(String fileName) throws FileNotFoundException {
- File m = new File("test1");
- File my = new File("test2");
- File myf = new File("test3");
- File myfi = new File("test4");
- File myfil = new File("test5");
- FileReader fileReader = new FileReader(m);
- BufferedReader bufferedReader = new BufferedReader(fileReader);
-
+ private static final String SEPARATOR_OF_WORDS = " ";
+ public String[] readFromFile(String fileName) { //write your code here
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(fileName));
+ int value = reader.read();
+ StringBuilder builder = new StringBuilder();
+ while (value != -1) {
+ builder.append((char) value);
+ value = reader.read(); }
+ String [] words = builder.toString().toLowerCase().split("\\W+");
+ StringBuilder resultBuilder = new StringBuilder();
+ for (String word : words) { if (word.charAt(0) == 'w') {
+ resultBuilder.append(word).append(SEPARATOR_OF_WORDS); }
+ } if (resultBuilder.toString().isEmpty()) {
+ return new String[0]; }
+ String [] appropriateWords = resultBuilder.toString().trim().split(SEPARATOR_OF_WORDS);
+ Arrays.sort(appropriateWords);
+ return appropriateWords; } catch (IOException e) {
+ throw new RuntimeException("Can't read file " + e);
+ } catch (StringIndexOutOfBoundsException e) {
+ return new String[0];
+ }
}
-}
+}
\ No newline at end of file
From 9ab886269dd25d78fc0efa46e311dfd7ecfaa970 Mon Sep 17 00:00:00 2001
From: DankevichMisha <83833016+DankevichMisha@users.noreply.github.com>
Date: Mon, 9 Oct 2023 10:28:52 +0300
Subject: [PATCH 03/10] Add files via upload
---
.../main/java/core/basesyntax/FileWork.java | 33 ++-
.../target/checkstyle-cachefile | 3 +
.../target/checkstyle-checker.xml | 250 ++++++++++++++++++
.../target/checkstyle-result.xml | 5 +
.../classes/core/basesyntax/FileWork.class | Bin 0 -> 2384 bytes
.../compile/default-compile/createdFiles.lst | 1 +
.../compile/default-compile/inputFiles.lst | 1 +
.../default-testCompile/createdFiles.lst | 1 +
.../default-testCompile/inputFiles.lst | 1 +
.../TEST-core.basesyntax.FileWorkTest.xml | 73 +++++
.../core.basesyntax.FileWorkTest.txt | 4 +
.../core/basesyntax/FileWorkTest.class | Bin 0 -> 5277 bytes
12 files changed, 362 insertions(+), 10 deletions(-)
create mode 100644 jv-read-from-file1/target/checkstyle-cachefile
create mode 100644 jv-read-from-file1/target/checkstyle-checker.xml
create mode 100644 jv-read-from-file1/target/checkstyle-result.xml
create mode 100644 jv-read-from-file1/target/classes/core/basesyntax/FileWork.class
create mode 100644 jv-read-from-file1/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
create mode 100644 jv-read-from-file1/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
create mode 100644 jv-read-from-file1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
create mode 100644 jv-read-from-file1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
create mode 100644 jv-read-from-file1/target/surefire-reports/TEST-core.basesyntax.FileWorkTest.xml
create mode 100644 jv-read-from-file1/target/surefire-reports/core.basesyntax.FileWorkTest.txt
create mode 100644 jv-read-from-file1/target/test-classes/core/basesyntax/FileWorkTest.class
diff --git a/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java b/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
index 7188e823..4a8acba8 100644
--- a/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
+++ b/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
@@ -1,28 +1,41 @@
package core.basesyntax;
-import java.io.BufferedReader;import java.io.FileReader;
-import java.io.IOException;import java.util.Arrays;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Arrays;
+
public class FileWork {
+
private static final String SEPARATOR_OF_WORDS = " ";
- public String[] readFromFile(String fileName) { //write your code here
+
+ public String[] readFromFile(String fileName) {
try {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
int value = reader.read();
StringBuilder builder = new StringBuilder();
while (value != -1) {
builder.append((char) value);
- value = reader.read(); }
+ value = reader.read();
+ }
String [] words = builder.toString().toLowerCase().split("\\W+");
StringBuilder resultBuilder = new StringBuilder();
- for (String word : words) { if (word.charAt(0) == 'w') {
- resultBuilder.append(word).append(SEPARATOR_OF_WORDS); }
- } if (resultBuilder.toString().isEmpty()) {
- return new String[0]; }
+ for (String word : words) {
+ if (word.charAt(0) == 'w') {
+ resultBuilder.append(word).append(SEPARATOR_OF_WORDS);
+ }
+ }
+ if (resultBuilder.toString().isEmpty()) {
+ return new String[0];
+ }
String [] appropriateWords = resultBuilder.toString().trim().split(SEPARATOR_OF_WORDS);
Arrays.sort(appropriateWords);
- return appropriateWords; } catch (IOException e) {
+ return appropriateWords;
+ } catch (IOException e) {
throw new RuntimeException("Can't read file " + e);
} catch (StringIndexOutOfBoundsException e) {
return new String[0];
}
}
-}
\ No newline at end of file
+
+}
diff --git a/jv-read-from-file1/target/checkstyle-cachefile b/jv-read-from-file1/target/checkstyle-cachefile
new file mode 100644
index 00000000..4898130a
--- /dev/null
+++ b/jv-read-from-file1/target/checkstyle-cachefile
@@ -0,0 +1,3 @@
+#Mon Oct 09 10:27:43 EEST 2023
+/Users/mihail/githubprojects/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java=1696836447898
+configuration*?=93620E16C42B1E083383B1E9D0BEA4FD5DCD7D93
diff --git a/jv-read-from-file1/target/checkstyle-checker.xml b/jv-read-from-file1/target/checkstyle-checker.xml
new file mode 100644
index 00000000..ea0a5295
--- /dev/null
+++ b/jv-read-from-file1/target/checkstyle-checker.xml
@@ -0,0 +1,250 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
diff --git a/jv-read-from-file1/target/checkstyle-result.xml b/jv-read-from-file1/target/checkstyle-result.xml
new file mode 100644
index 00000000..e457b26c
--- /dev/null
+++ b/jv-read-from-file1/target/checkstyle-result.xml
@@ -0,0 +1,5 @@
+
+
+
+
+
diff --git a/jv-read-from-file1/target/classes/core/basesyntax/FileWork.class b/jv-read-from-file1/target/classes/core/basesyntax/FileWork.class
new file mode 100644
index 0000000000000000000000000000000000000000..3564ca061e2f441ccb880b2fa6880d2e56878225
GIT binary patch
literal 2384
zcmaJ@&vz456#ibDWYX!BmX;KPw3HvEDFvc{pe>?JXr+=8Xli2t#c497Lz9^}ne>Os
zN|qiMcsxhl=wZVVHn>SS6!09D{saCOu3b^TH%VwP#YNta`|iE(yZ3%~UjBUX_!)rH
zxTT^A%?f-P{0Ini+|-x!Xim3oM3Zwjjf^W0IAdC-dsd)1GB~3kDA4UGnRYZ*nx8iu
zBRgg2S;JAF3Ut=a#?72jk*jEdCjGYwgd&N}8&a-gS~o@pXH+O?ml_=cT~!Ubub5ZQ
zJ2iA+hk(!FWgeIb1>FKW|LZSSGIKV)kNSZ}74C1hW
zzgWnbO!B~1dAZtv(!27AhNC#ffHDiZGfHD$WMVKbfxjt3eM{izR^A$%)k0QqLSR?M
zc8us8aTZrCS6_+B`lW4WF^IPXM4tqGTEjbdS3og~WBG!+>Q&*2JQ>k&My9~Wisn_E
z#rq0A&@hTvEiEP2%tc2XM_(;ct!O*M-5sfqu);T1TfsTfpvI$#n
zy;<+6lI5Ctu0E|I_Dtj6C)XDY^^DYz^!xCytSK4E2zm1N0H&d2PMl`XzR&)!LmT^gMl
zolZ_&PmW(tC#TM(C~WjD&{l&qBco(O<93!)d&0Dgi>3UW;Y{muIZ8Scc1F+5=#DA(
zRiV#aFd574#OrE4BB04O8+YuyD$OVm
zZV01BKUzrV1k_behiY;et78;PIk&1#KCzD-yTFKCNlF2sSaEt@x3W2-cranxi>1Oy
zLu~buR}80D3r786HNEv2-=a6FF5-GFmoi;rB#0$}?Qz{2aQh?``eeHL1nDwiS^Ui9
z^ddhX3K&CwL#SItpx`Tk-v3u6?JD82y^r&`0?1uVA;o!`yC$6Ek2FGn2`_Iw@6>^fRzht|-#hHaBa%GiE(
z9iiDZ>>T#>H2s3Eu&?J%8N1Tn(Y=ko!@e^1l+oAOU&g?&zor}r`-hdV^6XTw`BY1&
zB^11iNLUHA93NK0YI7Mw9m~I>BOC~;Wkfqqa!B895%)I!3I{xYr+z}P`6>22tnP=U
z&VY3J2=9fJhm-3Vn?3RfA3nwfU=7JXCOvid7{?vlM;zbdH*c2vC%EM8<=hOJnHfGF
zz&3QCovRK$f7@{YofzVqdxDY}y6Jf*4D3PyVcg>S8|=Y%=%J^*xQjmAV|nglKOWHX
z317sg==U;RU^b=QRTfO8@1JoEpR!;f{D9AJod|mIEk1`%v@tAT4jES90#CA(1?W3S
z`waggJRquh+@S4KYRpqtlHqx^hH__U!6FYh
ulDz2u2mbaA#@JNR0gd996)!zGI%`567Uv)-V)IwRGIuIhEBF#$Bm6HSuv?D+
literal 0
HcmV?d00001
diff --git a/jv-read-from-file1/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/jv-read-from-file1/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
new file mode 100644
index 00000000..e6d0a8b1
--- /dev/null
+++ b/jv-read-from-file1/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
@@ -0,0 +1 @@
+core/basesyntax/FileWork.class
diff --git a/jv-read-from-file1/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/jv-read-from-file1/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
new file mode 100644
index 00000000..1816b96f
--- /dev/null
+++ b/jv-read-from-file1/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
@@ -0,0 +1 @@
+/Users/mihail/githubprojects/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
diff --git a/jv-read-from-file1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/jv-read-from-file1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
new file mode 100644
index 00000000..9b00d16a
--- /dev/null
+++ b/jv-read-from-file1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
@@ -0,0 +1 @@
+core/basesyntax/FileWorkTest.class
diff --git a/jv-read-from-file1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/jv-read-from-file1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
new file mode 100644
index 00000000..51aa4f9b
--- /dev/null
+++ b/jv-read-from-file1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
@@ -0,0 +1 @@
+/Users/mihail/githubprojects/jv-read-from-file1/src/test/java/core/basesyntax/FileWorkTest.java
diff --git a/jv-read-from-file1/target/surefire-reports/TEST-core.basesyntax.FileWorkTest.xml b/jv-read-from-file1/target/surefire-reports/TEST-core.basesyntax.FileWorkTest.xml
new file mode 100644
index 00000000..ab97bfb7
--- /dev/null
+++ b/jv-read-from-file1/target/surefire-reports/TEST-core.basesyntax.FileWorkTest.xml
@@ -0,0 +1,73 @@
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
\ No newline at end of file
diff --git a/jv-read-from-file1/target/surefire-reports/core.basesyntax.FileWorkTest.txt b/jv-read-from-file1/target/surefire-reports/core.basesyntax.FileWorkTest.txt
new file mode 100644
index 00000000..4cc59a18
--- /dev/null
+++ b/jv-read-from-file1/target/surefire-reports/core.basesyntax.FileWorkTest.txt
@@ -0,0 +1,4 @@
+-------------------------------------------------------------------------------
+Test set: core.basesyntax.FileWorkTest
+-------------------------------------------------------------------------------
+Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.372 sec
diff --git a/jv-read-from-file1/target/test-classes/core/basesyntax/FileWorkTest.class b/jv-read-from-file1/target/test-classes/core/basesyntax/FileWorkTest.class
new file mode 100644
index 0000000000000000000000000000000000000000..c7cb4fcb8b041521b63462758985403d0368fd0a
GIT binary patch
literal 5277
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
Date: Mon, 9 Oct 2023 10:36:19 +0300
Subject: [PATCH 04/10] Add files via upload
---
jv-read-from-file1/target/checkstyle-cachefile | 2 +-
jv-read-from-file1/target/checkstyle-result.xml | 2 --
.../TEST-core.basesyntax.FileWorkTest.xml | 10 +++++-----
.../surefire-reports/core.basesyntax.FileWorkTest.txt | 2 +-
4 files changed, 7 insertions(+), 9 deletions(-)
diff --git a/jv-read-from-file1/target/checkstyle-cachefile b/jv-read-from-file1/target/checkstyle-cachefile
index 4898130a..2367e3cb 100644
--- a/jv-read-from-file1/target/checkstyle-cachefile
+++ b/jv-read-from-file1/target/checkstyle-cachefile
@@ -1,3 +1,3 @@
-#Mon Oct 09 10:27:43 EEST 2023
+#Mon Oct 09 10:30:53 EEST 2023
/Users/mihail/githubprojects/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java=1696836447898
configuration*?=93620E16C42B1E083383B1E9D0BEA4FD5DCD7D93
diff --git a/jv-read-from-file1/target/checkstyle-result.xml b/jv-read-from-file1/target/checkstyle-result.xml
index e457b26c..54aaa197 100644
--- a/jv-read-from-file1/target/checkstyle-result.xml
+++ b/jv-read-from-file1/target/checkstyle-result.xml
@@ -1,5 +1,3 @@
-
-
diff --git a/jv-read-from-file1/target/surefire-reports/TEST-core.basesyntax.FileWorkTest.xml b/jv-read-from-file1/target/surefire-reports/TEST-core.basesyntax.FileWorkTest.xml
index ab97bfb7..3270fb1e 100644
--- a/jv-read-from-file1/target/surefire-reports/TEST-core.basesyntax.FileWorkTest.xml
+++ b/jv-read-from-file1/target/surefire-reports/TEST-core.basesyntax.FileWorkTest.xml
@@ -1,5 +1,5 @@
-
+
@@ -65,9 +65,9 @@
-
-
+
+
-
-
+
+
\ No newline at end of file
diff --git a/jv-read-from-file1/target/surefire-reports/core.basesyntax.FileWorkTest.txt b/jv-read-from-file1/target/surefire-reports/core.basesyntax.FileWorkTest.txt
index 4cc59a18..3f4e773a 100644
--- a/jv-read-from-file1/target/surefire-reports/core.basesyntax.FileWorkTest.txt
+++ b/jv-read-from-file1/target/surefire-reports/core.basesyntax.FileWorkTest.txt
@@ -1,4 +1,4 @@
-------------------------------------------------------------------------------
Test set: core.basesyntax.FileWorkTest
-------------------------------------------------------------------------------
-Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.372 sec
+Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.435 sec
From de1cc404ed985b36e87bcd8801720800c702c630 Mon Sep 17 00:00:00 2001
From: DankevichMisha <83833016+DankevichMisha@users.noreply.github.com>
Date: Mon, 9 Oct 2023 14:18:58 +0300
Subject: [PATCH 05/10] Add files via upload
second try
---
jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java | 2 --
1 file changed, 2 deletions(-)
diff --git a/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java b/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
index 4a8acba8..8c90db4a 100644
--- a/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
+++ b/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
@@ -6,9 +6,7 @@
import java.util.Arrays;
public class FileWork {
-
private static final String SEPARATOR_OF_WORDS = " ";
-
public String[] readFromFile(String fileName) {
try {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
From 2068aaf25c7556f0cd80fc4d03c1c91e754481ed Mon Sep 17 00:00:00 2001
From: DankevichMisha <83833016+DankevichMisha@users.noreply.github.com>
Date: Fri, 13 Oct 2023 11:29:32 +0300
Subject: [PATCH 06/10] Add files via upload
---
.../main/java/core/basesyntax/FileWork.java | 1 +
.../target/checkstyle-cachefile | 4 ++--
.../target/checkstyle-result.xml | 2 ++
.../classes/core/basesyntax/FileWork.class | Bin 2384 -> 2384 bytes
.../TEST-core.basesyntax.FileWorkTest.xml | 12 ++++++------
.../core.basesyntax.FileWorkTest.txt | 2 +-
6 files changed, 12 insertions(+), 9 deletions(-)
diff --git a/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java b/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
index 8c90db4a..c45d299f 100644
--- a/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
+++ b/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
@@ -7,6 +7,7 @@
public class FileWork {
private static final String SEPARATOR_OF_WORDS = " ";
+
public String[] readFromFile(String fileName) {
try {
BufferedReader reader = new BufferedReader(new FileReader(fileName));
diff --git a/jv-read-from-file1/target/checkstyle-cachefile b/jv-read-from-file1/target/checkstyle-cachefile
index 2367e3cb..8c4bd2d6 100644
--- a/jv-read-from-file1/target/checkstyle-cachefile
+++ b/jv-read-from-file1/target/checkstyle-cachefile
@@ -1,3 +1,3 @@
-#Mon Oct 09 10:30:53 EEST 2023
-/Users/mihail/githubprojects/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java=1696836447898
+#Fri Oct 13 11:28:31 EEST 2023
+/Users/mihail/githubprojects/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java=1697185695341
configuration*?=93620E16C42B1E083383B1E9D0BEA4FD5DCD7D93
diff --git a/jv-read-from-file1/target/checkstyle-result.xml b/jv-read-from-file1/target/checkstyle-result.xml
index 54aaa197..e457b26c 100644
--- a/jv-read-from-file1/target/checkstyle-result.xml
+++ b/jv-read-from-file1/target/checkstyle-result.xml
@@ -1,3 +1,5 @@
+
+
diff --git a/jv-read-from-file1/target/classes/core/basesyntax/FileWork.class b/jv-read-from-file1/target/classes/core/basesyntax/FileWork.class
index 3564ca061e2f441ccb880b2fa6880d2e56878225..e1727510f0ad65d1cef39b539caedb1877cf9e91 100644
GIT binary patch
delta 93
zcmca0bU|o?7)Ky4g8%~`gD3+(gB*~h%pl01%^<{J%pk(x1QhjV5MxMX5N9Z0kYK0<
svYQ#C8TuGx7$yT%FJh2qSk9opu!=#EVKsvi!ycgSy$mXo(>Y!O0A-X9EC2ui
delta 93
zcmca0bU|o?7)Kx|&~0ck}KK>z>%
diff --git a/jv-read-from-file1/target/surefire-reports/TEST-core.basesyntax.FileWorkTest.xml b/jv-read-from-file1/target/surefire-reports/TEST-core.basesyntax.FileWorkTest.xml
index 3270fb1e..18f62864 100644
--- a/jv-read-from-file1/target/surefire-reports/TEST-core.basesyntax.FileWorkTest.xml
+++ b/jv-read-from-file1/target/surefire-reports/TEST-core.basesyntax.FileWorkTest.xml
@@ -1,5 +1,5 @@
-
+
@@ -65,9 +65,9 @@
-
-
-
-
-
+
+
+
+
+
\ No newline at end of file
diff --git a/jv-read-from-file1/target/surefire-reports/core.basesyntax.FileWorkTest.txt b/jv-read-from-file1/target/surefire-reports/core.basesyntax.FileWorkTest.txt
index 3f4e773a..8cd42e50 100644
--- a/jv-read-from-file1/target/surefire-reports/core.basesyntax.FileWorkTest.txt
+++ b/jv-read-from-file1/target/surefire-reports/core.basesyntax.FileWorkTest.txt
@@ -1,4 +1,4 @@
-------------------------------------------------------------------------------
Test set: core.basesyntax.FileWorkTest
-------------------------------------------------------------------------------
-Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.435 sec
+Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.613 sec
From 6893a6fa4319f1d05cdfe782f85d6b6f76bfe024 Mon Sep 17 00:00:00 2001
From: DankevichMisha <83833016+DankevichMisha@users.noreply.github.com>
Date: Fri, 13 Oct 2023 11:55:06 +0300
Subject: [PATCH 07/10] Add files via upload
---
.../src/main/java/core/basesyntax/FileWork.java | 1 -
jv-read-from-file1/target/checkstyle-cachefile | 4 ++--
.../TEST-core.basesyntax.FileWorkTest.xml | 10 +++++-----
.../surefire-reports/core.basesyntax.FileWorkTest.txt | 2 +-
4 files changed, 8 insertions(+), 9 deletions(-)
diff --git a/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java b/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
index c45d299f..cf0cccde 100644
--- a/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
+++ b/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
@@ -36,5 +36,4 @@ public String[] readFromFile(String fileName) {
return new String[0];
}
}
-
}
diff --git a/jv-read-from-file1/target/checkstyle-cachefile b/jv-read-from-file1/target/checkstyle-cachefile
index 8c4bd2d6..ca390169 100644
--- a/jv-read-from-file1/target/checkstyle-cachefile
+++ b/jv-read-from-file1/target/checkstyle-cachefile
@@ -1,3 +1,3 @@
-#Fri Oct 13 11:28:31 EEST 2023
-/Users/mihail/githubprojects/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java=1697185695341
+#Fri Oct 13 11:53:21 EEST 2023
+/Users/mihail/githubprojects/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java=1697187139661
configuration*?=93620E16C42B1E083383B1E9D0BEA4FD5DCD7D93
diff --git a/jv-read-from-file1/target/surefire-reports/TEST-core.basesyntax.FileWorkTest.xml b/jv-read-from-file1/target/surefire-reports/TEST-core.basesyntax.FileWorkTest.xml
index 18f62864..0b21a795 100644
--- a/jv-read-from-file1/target/surefire-reports/TEST-core.basesyntax.FileWorkTest.xml
+++ b/jv-read-from-file1/target/surefire-reports/TEST-core.basesyntax.FileWorkTest.xml
@@ -1,5 +1,5 @@
-
+
@@ -65,9 +65,9 @@
-
-
-
-
+
+
+
+
\ No newline at end of file
diff --git a/jv-read-from-file1/target/surefire-reports/core.basesyntax.FileWorkTest.txt b/jv-read-from-file1/target/surefire-reports/core.basesyntax.FileWorkTest.txt
index 8cd42e50..86dfbe5c 100644
--- a/jv-read-from-file1/target/surefire-reports/core.basesyntax.FileWorkTest.txt
+++ b/jv-read-from-file1/target/surefire-reports/core.basesyntax.FileWorkTest.txt
@@ -1,4 +1,4 @@
-------------------------------------------------------------------------------
Test set: core.basesyntax.FileWorkTest
-------------------------------------------------------------------------------
-Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.613 sec
+Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.13 sec
From 11ffb7cc11aa342dfdb7428f75e71ef26cec45db Mon Sep 17 00:00:00 2001
From: DankevichMisha <83833016+DankevichMisha@users.noreply.github.com>
Date: Fri, 13 Oct 2023 13:46:38 +0300
Subject: [PATCH 08/10] Add files via upload
---
jv-read-from-file12/README.md | 22 +++++
jv-read-from-file12/checklist.md | 55 +++++++++++
jv-read-from-file12/pom.xml | 67 +++++++++++++
.../main/java/core/basesyntax/FileWork.java | 39 ++++++++
.../java/core/basesyntax/FileWorkTest.java | 99 +++++++++++++++++++
jv-read-from-file12/test1 | 0
jv-read-from-file12/test2 | 6 ++
jv-read-from-file12/test3 | 4 +
jv-read-from-file12/test4 | 4 +
jv-read-from-file12/test5 | 4 +
10 files changed, 300 insertions(+)
create mode 100644 jv-read-from-file12/README.md
create mode 100644 jv-read-from-file12/checklist.md
create mode 100644 jv-read-from-file12/pom.xml
create mode 100644 jv-read-from-file12/src/main/java/core/basesyntax/FileWork.java
create mode 100644 jv-read-from-file12/src/test/java/core/basesyntax/FileWorkTest.java
create mode 100644 jv-read-from-file12/test1
create mode 100644 jv-read-from-file12/test2
create mode 100644 jv-read-from-file12/test3
create mode 100644 jv-read-from-file12/test4
create mode 100644 jv-read-from-file12/test5
diff --git a/jv-read-from-file12/README.md b/jv-read-from-file12/README.md
new file mode 100644
index 00000000..7bf39057
--- /dev/null
+++ b/jv-read-from-file12/README.md
@@ -0,0 +1,22 @@
+# jv-read-from-file
+You are given a file that contains different words as well as punctuation.
+
+You need to filter out only the words starting with `w`, and remove any punctuation if necessary.
+
+The result should be returned as a naturally sorted array.
+All words should be lower-case.
+
+If the file does not contain the necessary words, return an empty array.
+
+Examples:
+```
+"Width world Wide web"
+Result: ["web", "wide", "width", "world"]
+
+"WWW? Four-bedroom farmhouse in the countryside. Wave! All of the four double bedrooms are en suite."
+Result: ["wave", "www"]
+```
+
+Hint: try to split Strings with a regular expression that includes whitespace and punctuation characters.
+Here is a good [article](https://stackoverflow.com/questions/13225175/java-string-split-with-a-regex).
+#### [Try to avoid these common mistakes, while solving task](https://mate-academy.github.io/jv-program-common-mistakes/java-core/builder-file/read-from-file.html)
diff --git a/jv-read-from-file12/checklist.md b/jv-read-from-file12/checklist.md
new file mode 100644
index 00000000..baefe4f6
--- /dev/null
+++ b/jv-read-from-file12/checklist.md
@@ -0,0 +1,55 @@
+### Common mistakes
+
+#### Create variables with informative names.
+
+Bad naming:
+```java
+BufferedReader br = new BufferedReader(new FileReader(fileName))
+```
+
+Good naming:
+```java
+BufferedReader bufferedReader = new BufferedReader(new FileReader(fileName))
+```
+
+#### Use constants where applicable.
+If you have strange strings or numbers in the code it's better to declare them as constants.
+The name of the constant should display this object's purpose.
+
+Bad practice:
+```java
+ public boolean startWithLetter(String word) {
+ return word.startsWith("d"); // why do we use 'd' here???
+ }
+```
+
+Good practice:
+```java
+ private static final String SPECIFIED_CHARACTER = "d";
+
+ public boolean startWithLetter(String word) {
+ return word.startsWith(SPECIFIED_CHARACTER);
+ }
+```
+[Correct constant names](https://google.github.io/styleguide/javaguide.html#s5.2.4-constant-names)
+
+#### Close all resources.
+Connections, streams, files, and other classes that implement the `Closeable` or `AutoCloseable` interface,
+needs to be closed after use. Furthermore, that close should be done in a `finally` block.
+Preferably, when class implements `AutoCloseable`, resource should be created using "try-with-resources" pattern
+and will be closed automatically.
+
+#### Don't ignore exceptions.
+Leaving empty catch block or `e.printStackTrace` here is a bad practice.
+Better re-throw `RuntimeException` with original exception in the parameters:
+```java
+catch (Exception e) {
+ throw new RuntimeException(e);
+}
+```
+
+#### Don't create redundant variables.
+Let's make your code simple and easy to read. So better avoid using redundant variables.
+
+#### Use System.lineSeparator() insted `\n`
+[explanation](https://www.geeksforgeeks.org/system-lineseparator-method-in-java-with-examples/)
diff --git a/jv-read-from-file12/pom.xml b/jv-read-from-file12/pom.xml
new file mode 100644
index 00000000..60c679a0
--- /dev/null
+++ b/jv-read-from-file12/pom.xml
@@ -0,0 +1,67 @@
+
+
+ 4.0.0
+
+ mate-academy
+ read-from-file
+ 1.0-SNAPSHOT
+
+
+ 11
+ UTF-8
+ UTF-8
+ 3.1.1
+
+ https://raw.githubusercontent.com/mate-academy/style-guides/master/java/checkstyle.xml
+
+
+
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ 3.1.1
+
+
+ compile
+
+ check
+
+
+
+
+ ${maven.checkstyle.plugin.configLocation}
+ UTF-8
+ true
+ true
+ false
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+ 3.8.0
+
+
+ ${jdk.version}
+ ${project.build.sourceEncoding}
+
+
+
+
+
+
diff --git a/jv-read-from-file12/src/main/java/core/basesyntax/FileWork.java b/jv-read-from-file12/src/main/java/core/basesyntax/FileWork.java
new file mode 100644
index 00000000..7884760f
--- /dev/null
+++ b/jv-read-from-file12/src/main/java/core/basesyntax/FileWork.java
@@ -0,0 +1,39 @@
+package core.basesyntax;
+
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Arrays;
+
+public class FileWork {
+ private static final String SEPARATOR_OF_WORDS = " ";
+
+ public String[] readFromFile(String fileName) {
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(fileName));
+ int value = reader.read();
+ StringBuilder builder = new StringBuilder();
+ while (value != -1) {
+ builder.append((char) value);
+ value = reader.read();
+ }
+ String [] words = builder.toString().toLowerCase().split("\\W+");
+ StringBuilder resultBuilder = new StringBuilder();
+ for (String word : words) {
+ if (word.charAt(0) == 'w') {
+ resultBuilder.append(word).append(SEPARATOR_OF_WORDS);
+ }
+ }
+ if (resultBuilder.toString().isEmpty()) {
+ return new String[0];
+ }
+ String [] appropriateWords = resultBuilder.toString().trim().split(SEPARATOR_OF_WORDS);
+ Arrays.sort(appropriateWords);
+ return appropriateWords;
+ } catch (IOException e) {
+ throw new RuntimeException("Can't read file " + e);
+ } catch (StringIndexOutOfBoundsException e) {
+ return new String[0];
+ }
+ }
+}
diff --git a/jv-read-from-file12/src/test/java/core/basesyntax/FileWorkTest.java b/jv-read-from-file12/src/test/java/core/basesyntax/FileWorkTest.java
new file mode 100644
index 00000000..2e2f9393
--- /dev/null
+++ b/jv-read-from-file12/src/test/java/core/basesyntax/FileWorkTest.java
@@ -0,0 +1,99 @@
+package core.basesyntax;
+
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.util.Arrays;
+import org.junit.Assert;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+public class FileWorkTest {
+ private static final String TEMP_DIRECTORY = System.getProperty("java.io.tmpdir") + "/";
+ private static final String EMPTY_FILE_NAME = TEMP_DIRECTORY + "test1";
+ private static final String SECOND_FILE_NAME = TEMP_DIRECTORY + "test2";
+ private static final String THIRD_FILE_NAME = TEMP_DIRECTORY + "test3";
+ private static final String FOURS_FILE_NAME = TEMP_DIRECTORY + "test4";
+ private static final String FIFTH_FILE_NAME = TEMP_DIRECTORY + "test5";
+
+ private static final String[] EMPTY_ARRAY_RESULT = new String[0];
+ private static final String[] RESULT_FROM_LOWER_CASE =
+ new String[]{"walk", "warm", "with", "with"};
+ private static final String[] RESULT_FROM_CAMEL_CASE =
+ new String[]{"wall", "wave", "width", "world", "www"};
+ private static final String[] RESULT_FROM_ADJACENT_WORDS_CASE =
+ new String[]{"was", "was", "whenever", "which", "which", "worse"};
+
+ @BeforeClass
+ public static void beforeClass() throws Exception{
+ Files.write(Path.of(EMPTY_FILE_NAME), "".getBytes(StandardCharsets.UTF_8));
+ Files.write(Path.of(SECOND_FILE_NAME), (
+ "Beautiful two-bedroom city flat five minutes' walk from the cathedral.\n" +
+ "Fully equipped kitchen, living room with a large sofa and chairs, big TV and balcony.\n" +
+ "The balcony has space for four people to sit and gets the sun in the mornings,\n" +
+ "and the flat is light and warm. The upstairs bedroom sleeps four people, with two double beds;\n" +
+ "the downstairs bedroom sleeps two in single beds.\n" +
+ "The flat is perfect for families and is near shops, bars and restaurants.\n").getBytes(StandardCharsets.UTF_8));
+ Files.write(Path.of(THIRD_FILE_NAME), (
+ "Four-bedroom farmhouse in the countryside. All of the four double bedrooms are en suite.\n" +
+ "Farm kitchen, tables and chairs outside. Great for groups of friends. The supermarket is half\n" +
+ "an hour by car and you can take a train from the village into the city. Escape from normal life\n" +
+ "for a few days.\n").getBytes(StandardCharsets.UTF_8));
+ Files.write(Path.of(FOURS_FILE_NAME), (
+ "WWW? Four-bedroom farmhouse in the countryside. Wave! All of the four double bedrooms are en suite.\n" +
+ "Farm kitchen, tables and chairs outside. Great for groups of friends. World and the supermarket is\n" +
+ "half an hour by car and you can take a train from wall the village into the city. Escape from normal\n" +
+ "life for a few days, width.\n").getBytes(StandardCharsets.UTF_8));
+ Files.write(Path.of(FIFTH_FILE_NAME), (
+ "Whenever I have gone there, there have been either so many\n" +
+ "people that I have not been able to see the pictures, which\n" +
+ "was dreadful, or so many pictures that I have not been able to see the people, which was\n" +
+ "worse. The Grosvenor is really the only place.\"\n").getBytes(StandardCharsets.UTF_8));
+ }
+
+ @Test
+ public void readFromEmptyFile() {
+ FileWork fileWork = new FileWork();
+ String[] actualResult = fileWork.readFromFile(EMPTY_FILE_NAME);
+ Assert.assertArrayEquals("Test failed! You should returned empty array.",
+ EMPTY_ARRAY_RESULT, actualResult);
+ }
+
+ @Test
+ public void getLowerCaseResultFromFile() {
+ FileWork fileWork = new FileWork();
+ String[] actualResult = fileWork.readFromFile(SECOND_FILE_NAME);
+ Assert.assertArrayEquals("Test failed! You should returned next array "
+ + Arrays.toString(RESULT_FROM_LOWER_CASE) + " but you returned "
+ + Arrays.toString(actualResult),
+ RESULT_FROM_LOWER_CASE, actualResult);
+ }
+
+ @Test
+ public void getCamelCaseResultFromFile() {
+ FileWork fileWork = new FileWork();
+ String[] actualResult = fileWork.readFromFile(FOURS_FILE_NAME);
+ Assert.assertArrayEquals("Test failed! You should returned next array "
+ + Arrays.toString(RESULT_FROM_CAMEL_CASE) + " but you returned "
+ + Arrays.toString(actualResult),
+ RESULT_FROM_CAMEL_CASE, actualResult);
+ }
+
+ @Test
+ public void getEmptyResultFromFile() {
+ FileWork fileWork = new FileWork();
+ String[] actualResult = fileWork.readFromFile(THIRD_FILE_NAME);
+ Assert.assertArrayEquals("Test failed! You should returned empty array.",
+ EMPTY_ARRAY_RESULT, actualResult);
+ }
+
+ @Test
+ public void getAdjacentWordsResultFromFile() {
+ FileWork fileWork = new FileWork();
+ String[] actualResult = fileWork.readFromFile(FIFTH_FILE_NAME);
+ Assert.assertArrayEquals("Test failed! You should returned next array "
+ + Arrays.toString(RESULT_FROM_ADJACENT_WORDS_CASE) + " but you returned "
+ + Arrays.toString(actualResult),
+ RESULT_FROM_ADJACENT_WORDS_CASE, actualResult);
+ }
+}
diff --git a/jv-read-from-file12/test1 b/jv-read-from-file12/test1
new file mode 100644
index 00000000..e69de29b
diff --git a/jv-read-from-file12/test2 b/jv-read-from-file12/test2
new file mode 100644
index 00000000..62ecaf9c
--- /dev/null
+++ b/jv-read-from-file12/test2
@@ -0,0 +1,6 @@
+Beautiful two-bedroom city flat five minutes' walk from the cathedral.
+Fully equipped kitchen, living room with a large sofa and chairs, big TV and balcony.
+The balcony has space for four people to sit and gets the sun in the mornings,
+and the flat is light and warm. The upstairs bedroom sleeps four people, with two double beds;
+the downstairs bedroom sleeps two in single beds.
+The flat is perfect for families and is near shops, bars and restaurants.
diff --git a/jv-read-from-file12/test3 b/jv-read-from-file12/test3
new file mode 100644
index 00000000..12c3961f
--- /dev/null
+++ b/jv-read-from-file12/test3
@@ -0,0 +1,4 @@
+Four-bedroom farmhouse in the countryside. All of the four double bedrooms are en suite.
+Farm kitchen, tables and chairs outside. Great for groups of friends. The supermarket is half
+an hour by car and you can take a train from the village into the city. Escape from normal life
+for a few days.
diff --git a/jv-read-from-file12/test4 b/jv-read-from-file12/test4
new file mode 100644
index 00000000..a5c34f4e
--- /dev/null
+++ b/jv-read-from-file12/test4
@@ -0,0 +1,4 @@
+WWW? Four-bedroom farmhouse in the countryside. Wave! All of the four double bedrooms are en suite.
+Farm kitchen, tables and chairs outside. Great for groups of friends. World and the supermarket is
+half an hour by car and you can take a train from wall the village into the city. Escape from normal
+life for a few days, width.
diff --git a/jv-read-from-file12/test5 b/jv-read-from-file12/test5
new file mode 100644
index 00000000..90465912
--- /dev/null
+++ b/jv-read-from-file12/test5
@@ -0,0 +1,4 @@
+Whenever I have gone there, there have been either so many
+people that I have not been able to see the pictures, which
+was dreadful, or so many pictures that I have not been able to see the people, which was
+worse. The Grosvenor is really the only place."
From 8d5c9a36b818861e7ffa86c64d37695b6df74aa6 Mon Sep 17 00:00:00 2001
From: Misha
Date: Fri, 13 Oct 2023 13:59:57 +0300
Subject: [PATCH 09/10] second try
---
jv-read-from-file1/README.md | 22 --
jv-read-from-file1/checklist.md | 55 ----
jv-read-from-file1/pom.xml | 67 -----
.../main/java/core/basesyntax/FileWork.java | 39 ---
.../java/core/basesyntax/FileWorkTest.java | 99 -------
.../target/checkstyle-cachefile | 3 -
.../target/checkstyle-checker.xml | 250 ------------------
.../target/checkstyle-result.xml | 5 -
.../classes/core/basesyntax/FileWork.class | Bin 2384 -> 0 bytes
.../compile/default-compile/createdFiles.lst | 1 -
.../compile/default-compile/inputFiles.lst | 1 -
.../default-testCompile/createdFiles.lst | 1 -
.../default-testCompile/inputFiles.lst | 1 -
.../TEST-core.basesyntax.FileWorkTest.xml | 73 -----
.../core.basesyntax.FileWorkTest.txt | 4 -
.../core/basesyntax/FileWorkTest.class | Bin 5277 -> 0 bytes
jv-read-from-file1/test1 | 0
jv-read-from-file1/test2 | 6 -
jv-read-from-file1/test3 | 4 -
jv-read-from-file1/test4 | 4 -
jv-read-from-file1/test5 | 4 -
jv-read-from-file12/README.md | 22 --
jv-read-from-file12/checklist.md | 55 ----
jv-read-from-file12/pom.xml | 67 -----
.../main/java/core/basesyntax/FileWork.java | 39 ---
.../java/core/basesyntax/FileWorkTest.java | 99 -------
jv-read-from-file12/test1 | 0
jv-read-from-file12/test2 | 6 -
jv-read-from-file12/test3 | 4 -
jv-read-from-file12/test4 | 4 -
jv-read-from-file12/test5 | 4 -
src/main/java/core/basesyntax/FileWork.java | 37 ++-
32 files changed, 34 insertions(+), 942 deletions(-)
delete mode 100644 jv-read-from-file1/README.md
delete mode 100644 jv-read-from-file1/checklist.md
delete mode 100644 jv-read-from-file1/pom.xml
delete mode 100644 jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
delete mode 100644 jv-read-from-file1/src/test/java/core/basesyntax/FileWorkTest.java
delete mode 100644 jv-read-from-file1/target/checkstyle-cachefile
delete mode 100644 jv-read-from-file1/target/checkstyle-checker.xml
delete mode 100644 jv-read-from-file1/target/checkstyle-result.xml
delete mode 100644 jv-read-from-file1/target/classes/core/basesyntax/FileWork.class
delete mode 100644 jv-read-from-file1/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
delete mode 100644 jv-read-from-file1/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
delete mode 100644 jv-read-from-file1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
delete mode 100644 jv-read-from-file1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
delete mode 100644 jv-read-from-file1/target/surefire-reports/TEST-core.basesyntax.FileWorkTest.xml
delete mode 100644 jv-read-from-file1/target/surefire-reports/core.basesyntax.FileWorkTest.txt
delete mode 100644 jv-read-from-file1/target/test-classes/core/basesyntax/FileWorkTest.class
delete mode 100644 jv-read-from-file1/test1
delete mode 100644 jv-read-from-file1/test2
delete mode 100644 jv-read-from-file1/test3
delete mode 100644 jv-read-from-file1/test4
delete mode 100644 jv-read-from-file1/test5
delete mode 100644 jv-read-from-file12/README.md
delete mode 100644 jv-read-from-file12/checklist.md
delete mode 100644 jv-read-from-file12/pom.xml
delete mode 100644 jv-read-from-file12/src/main/java/core/basesyntax/FileWork.java
delete mode 100644 jv-read-from-file12/src/test/java/core/basesyntax/FileWorkTest.java
delete mode 100644 jv-read-from-file12/test1
delete mode 100644 jv-read-from-file12/test2
delete mode 100644 jv-read-from-file12/test3
delete mode 100644 jv-read-from-file12/test4
delete mode 100644 jv-read-from-file12/test5
diff --git a/jv-read-from-file1/README.md b/jv-read-from-file1/README.md
deleted file mode 100644
index 7bf39057..00000000
--- a/jv-read-from-file1/README.md
+++ /dev/null
@@ -1,22 +0,0 @@
-# jv-read-from-file
-You are given a file that contains different words as well as punctuation.
-
-You need to filter out only the words starting with `w`, and remove any punctuation if necessary.
-
-The result should be returned as a naturally sorted array.
-All words should be lower-case.
-
-If the file does not contain the necessary words, return an empty array.
-
-Examples:
-```
-"Width world Wide web"
-Result: ["web", "wide", "width", "world"]
-
-"WWW? Four-bedroom farmhouse in the countryside. Wave! All of the four double bedrooms are en suite."
-Result: ["wave", "www"]
-```
-
-Hint: try to split Strings with a regular expression that includes whitespace and punctuation characters.
-Here is a good [article](https://stackoverflow.com/questions/13225175/java-string-split-with-a-regex).
-#### [Try to avoid these common mistakes, while solving task](https://mate-academy.github.io/jv-program-common-mistakes/java-core/builder-file/read-from-file.html)
diff --git a/jv-read-from-file1/checklist.md b/jv-read-from-file1/checklist.md
deleted file mode 100644
index baefe4f6..00000000
--- a/jv-read-from-file1/checklist.md
+++ /dev/null
@@ -1,55 +0,0 @@
-### Common mistakes
-
-#### Create variables with informative names.
-
-Bad naming:
-```java
-BufferedReader br = new BufferedReader(new FileReader(fileName))
-```
-
-Good naming:
-```java
-BufferedReader bufferedReader = new BufferedReader(new FileReader(fileName))
-```
-
-#### Use constants where applicable.
-If you have strange strings or numbers in the code it's better to declare them as constants.
-The name of the constant should display this object's purpose.
-
-Bad practice:
-```java
- public boolean startWithLetter(String word) {
- return word.startsWith("d"); // why do we use 'd' here???
- }
-```
-
-Good practice:
-```java
- private static final String SPECIFIED_CHARACTER = "d";
-
- public boolean startWithLetter(String word) {
- return word.startsWith(SPECIFIED_CHARACTER);
- }
-```
-[Correct constant names](https://google.github.io/styleguide/javaguide.html#s5.2.4-constant-names)
-
-#### Close all resources.
-Connections, streams, files, and other classes that implement the `Closeable` or `AutoCloseable` interface,
-needs to be closed after use. Furthermore, that close should be done in a `finally` block.
-Preferably, when class implements `AutoCloseable`, resource should be created using "try-with-resources" pattern
-and will be closed automatically.
-
-#### Don't ignore exceptions.
-Leaving empty catch block or `e.printStackTrace` here is a bad practice.
-Better re-throw `RuntimeException` with original exception in the parameters:
-```java
-catch (Exception e) {
- throw new RuntimeException(e);
-}
-```
-
-#### Don't create redundant variables.
-Let's make your code simple and easy to read. So better avoid using redundant variables.
-
-#### Use System.lineSeparator() insted `\n`
-[explanation](https://www.geeksforgeeks.org/system-lineseparator-method-in-java-with-examples/)
diff --git a/jv-read-from-file1/pom.xml b/jv-read-from-file1/pom.xml
deleted file mode 100644
index 60c679a0..00000000
--- a/jv-read-from-file1/pom.xml
+++ /dev/null
@@ -1,67 +0,0 @@
-
-
- 4.0.0
-
- mate-academy
- read-from-file
- 1.0-SNAPSHOT
-
-
- 11
- UTF-8
- UTF-8
- 3.1.1
-
- https://raw.githubusercontent.com/mate-academy/style-guides/master/java/checkstyle.xml
-
-
-
-
-
- junit
- junit
- 4.12
- test
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
- 3.1.1
-
-
- compile
-
- check
-
-
-
-
- ${maven.checkstyle.plugin.configLocation}
- UTF-8
- true
- true
- false
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.8.0
-
-
- ${jdk.version}
- ${project.build.sourceEncoding}
-
-
-
-
-
-
diff --git a/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java b/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
deleted file mode 100644
index cf0cccde..00000000
--- a/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package core.basesyntax;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.Arrays;
-
-public class FileWork {
- private static final String SEPARATOR_OF_WORDS = " ";
-
- public String[] readFromFile(String fileName) {
- try {
- BufferedReader reader = new BufferedReader(new FileReader(fileName));
- int value = reader.read();
- StringBuilder builder = new StringBuilder();
- while (value != -1) {
- builder.append((char) value);
- value = reader.read();
- }
- String [] words = builder.toString().toLowerCase().split("\\W+");
- StringBuilder resultBuilder = new StringBuilder();
- for (String word : words) {
- if (word.charAt(0) == 'w') {
- resultBuilder.append(word).append(SEPARATOR_OF_WORDS);
- }
- }
- if (resultBuilder.toString().isEmpty()) {
- return new String[0];
- }
- String [] appropriateWords = resultBuilder.toString().trim().split(SEPARATOR_OF_WORDS);
- Arrays.sort(appropriateWords);
- return appropriateWords;
- } catch (IOException e) {
- throw new RuntimeException("Can't read file " + e);
- } catch (StringIndexOutOfBoundsException e) {
- return new String[0];
- }
- }
-}
diff --git a/jv-read-from-file1/src/test/java/core/basesyntax/FileWorkTest.java b/jv-read-from-file1/src/test/java/core/basesyntax/FileWorkTest.java
deleted file mode 100644
index 2e2f9393..00000000
--- a/jv-read-from-file1/src/test/java/core/basesyntax/FileWorkTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package core.basesyntax;
-
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Arrays;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class FileWorkTest {
- private static final String TEMP_DIRECTORY = System.getProperty("java.io.tmpdir") + "/";
- private static final String EMPTY_FILE_NAME = TEMP_DIRECTORY + "test1";
- private static final String SECOND_FILE_NAME = TEMP_DIRECTORY + "test2";
- private static final String THIRD_FILE_NAME = TEMP_DIRECTORY + "test3";
- private static final String FOURS_FILE_NAME = TEMP_DIRECTORY + "test4";
- private static final String FIFTH_FILE_NAME = TEMP_DIRECTORY + "test5";
-
- private static final String[] EMPTY_ARRAY_RESULT = new String[0];
- private static final String[] RESULT_FROM_LOWER_CASE =
- new String[]{"walk", "warm", "with", "with"};
- private static final String[] RESULT_FROM_CAMEL_CASE =
- new String[]{"wall", "wave", "width", "world", "www"};
- private static final String[] RESULT_FROM_ADJACENT_WORDS_CASE =
- new String[]{"was", "was", "whenever", "which", "which", "worse"};
-
- @BeforeClass
- public static void beforeClass() throws Exception{
- Files.write(Path.of(EMPTY_FILE_NAME), "".getBytes(StandardCharsets.UTF_8));
- Files.write(Path.of(SECOND_FILE_NAME), (
- "Beautiful two-bedroom city flat five minutes' walk from the cathedral.\n" +
- "Fully equipped kitchen, living room with a large sofa and chairs, big TV and balcony.\n" +
- "The balcony has space for four people to sit and gets the sun in the mornings,\n" +
- "and the flat is light and warm. The upstairs bedroom sleeps four people, with two double beds;\n" +
- "the downstairs bedroom sleeps two in single beds.\n" +
- "The flat is perfect for families and is near shops, bars and restaurants.\n").getBytes(StandardCharsets.UTF_8));
- Files.write(Path.of(THIRD_FILE_NAME), (
- "Four-bedroom farmhouse in the countryside. All of the four double bedrooms are en suite.\n" +
- "Farm kitchen, tables and chairs outside. Great for groups of friends. The supermarket is half\n" +
- "an hour by car and you can take a train from the village into the city. Escape from normal life\n" +
- "for a few days.\n").getBytes(StandardCharsets.UTF_8));
- Files.write(Path.of(FOURS_FILE_NAME), (
- "WWW? Four-bedroom farmhouse in the countryside. Wave! All of the four double bedrooms are en suite.\n" +
- "Farm kitchen, tables and chairs outside. Great for groups of friends. World and the supermarket is\n" +
- "half an hour by car and you can take a train from wall the village into the city. Escape from normal\n" +
- "life for a few days, width.\n").getBytes(StandardCharsets.UTF_8));
- Files.write(Path.of(FIFTH_FILE_NAME), (
- "Whenever I have gone there, there have been either so many\n" +
- "people that I have not been able to see the pictures, which\n" +
- "was dreadful, or so many pictures that I have not been able to see the people, which was\n" +
- "worse. The Grosvenor is really the only place.\"\n").getBytes(StandardCharsets.UTF_8));
- }
-
- @Test
- public void readFromEmptyFile() {
- FileWork fileWork = new FileWork();
- String[] actualResult = fileWork.readFromFile(EMPTY_FILE_NAME);
- Assert.assertArrayEquals("Test failed! You should returned empty array.",
- EMPTY_ARRAY_RESULT, actualResult);
- }
-
- @Test
- public void getLowerCaseResultFromFile() {
- FileWork fileWork = new FileWork();
- String[] actualResult = fileWork.readFromFile(SECOND_FILE_NAME);
- Assert.assertArrayEquals("Test failed! You should returned next array "
- + Arrays.toString(RESULT_FROM_LOWER_CASE) + " but you returned "
- + Arrays.toString(actualResult),
- RESULT_FROM_LOWER_CASE, actualResult);
- }
-
- @Test
- public void getCamelCaseResultFromFile() {
- FileWork fileWork = new FileWork();
- String[] actualResult = fileWork.readFromFile(FOURS_FILE_NAME);
- Assert.assertArrayEquals("Test failed! You should returned next array "
- + Arrays.toString(RESULT_FROM_CAMEL_CASE) + " but you returned "
- + Arrays.toString(actualResult),
- RESULT_FROM_CAMEL_CASE, actualResult);
- }
-
- @Test
- public void getEmptyResultFromFile() {
- FileWork fileWork = new FileWork();
- String[] actualResult = fileWork.readFromFile(THIRD_FILE_NAME);
- Assert.assertArrayEquals("Test failed! You should returned empty array.",
- EMPTY_ARRAY_RESULT, actualResult);
- }
-
- @Test
- public void getAdjacentWordsResultFromFile() {
- FileWork fileWork = new FileWork();
- String[] actualResult = fileWork.readFromFile(FIFTH_FILE_NAME);
- Assert.assertArrayEquals("Test failed! You should returned next array "
- + Arrays.toString(RESULT_FROM_ADJACENT_WORDS_CASE) + " but you returned "
- + Arrays.toString(actualResult),
- RESULT_FROM_ADJACENT_WORDS_CASE, actualResult);
- }
-}
diff --git a/jv-read-from-file1/target/checkstyle-cachefile b/jv-read-from-file1/target/checkstyle-cachefile
deleted file mode 100644
index ca390169..00000000
--- a/jv-read-from-file1/target/checkstyle-cachefile
+++ /dev/null
@@ -1,3 +0,0 @@
-#Fri Oct 13 11:53:21 EEST 2023
-/Users/mihail/githubprojects/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java=1697187139661
-configuration*?=93620E16C42B1E083383B1E9D0BEA4FD5DCD7D93
diff --git a/jv-read-from-file1/target/checkstyle-checker.xml b/jv-read-from-file1/target/checkstyle-checker.xml
deleted file mode 100644
index ea0a5295..00000000
--- a/jv-read-from-file1/target/checkstyle-checker.xml
+++ /dev/null
@@ -1,250 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/jv-read-from-file1/target/checkstyle-result.xml b/jv-read-from-file1/target/checkstyle-result.xml
deleted file mode 100644
index e457b26c..00000000
--- a/jv-read-from-file1/target/checkstyle-result.xml
+++ /dev/null
@@ -1,5 +0,0 @@
-
-
-
-
-
diff --git a/jv-read-from-file1/target/classes/core/basesyntax/FileWork.class b/jv-read-from-file1/target/classes/core/basesyntax/FileWork.class
deleted file mode 100644
index e1727510f0ad65d1cef39b539caedb1877cf9e91..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 2384
zcmaJ@O;;0V6niJg)t=+Bf1v-O>#n5Fn@J=#*hSut``&xs=id9=ck<`+$4>#A
z!yOfMs8ur5mPguHrE0LbRZDf3b@OjfV{R;y1@xB=a5rNK
z-lm})9ReYjmzBVbD(Dp0^f!(pjjmAi^rlkbcF5
zgO|5VCb@UJyj-tAS-SGLh7&l+fHI4^J4EA9e6%kmfxjk0eO=(hcHU~7RYF#9T3~m^
zagD@0ae8aEudgO#{bn6^DS|fyM7IQePQ#mcOF%Kb;auKdD^=l|JQ>t*UZx<#isn>Y
zz&i@w)i8u)B`pQtv=T$EtFL)f^BkABJLA<627F_+6&bQ!xxp!Bv62Ex3XDsGT)d(*-}hkaP-m)_Z}Ty)!j@WoU9}
zIz4$aJ#uq4J$Z48!dmYF%@s&9GD;>iWp!RAyl#|O?UBfF_ep#J-VjsIso)P(ypwdtfVe|!}D#j2_f6c|OtN^tm
z3k-Kc&(UG?l&@!`SzDYYH*~>XcJ(Ge(e-=1Pa0lqDvvq~rLW@9Oz+!(Vi=UP~Bx
z6`z6+qbG?)#vk5dgJ~~2OGY9HGvL~Yp79-*ZS{RMWy^|z(@VOYwG8j@nBy!J@`E+8
zRZCtnoL6SHR`o>@c%K|%7y4~w{ODc5Bbae~TWz@F$%vrj}
z2Sfp5I8qbpb`dD}T%ha!RY|)bT(j&ERi?)W3T_ZXLfb)^3oFR3HMIPT(Cr0^|%Da~^KJFb-Wa;}HW%nUys
zKr>pggR2&P{#tPeJJF9eoJI$dlwL+B4D3Q4yK#r>FR>TjU>`ko;T{g)KDv2B4<6tk
zZ#aY}{3^;!=b24|HrH7&m41K34Sd9cMe!Xz#!VvV!q@l&I?*PvhPBSt7-4N{117jxGg?P!R3dBpy}4DFr=ck%A>2
va3pzg^`0V~|8T&?0We1X`%3^rSO
diff --git a/jv-read-from-file1/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst b/jv-read-from-file1/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
deleted file mode 100644
index e6d0a8b1..00000000
--- a/jv-read-from-file1/target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
+++ /dev/null
@@ -1 +0,0 @@
-core/basesyntax/FileWork.class
diff --git a/jv-read-from-file1/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst b/jv-read-from-file1/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
deleted file mode 100644
index 1816b96f..00000000
--- a/jv-read-from-file1/target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
+++ /dev/null
@@ -1 +0,0 @@
-/Users/mihail/githubprojects/jv-read-from-file1/src/main/java/core/basesyntax/FileWork.java
diff --git a/jv-read-from-file1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst b/jv-read-from-file1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
deleted file mode 100644
index 9b00d16a..00000000
--- a/jv-read-from-file1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
+++ /dev/null
@@ -1 +0,0 @@
-core/basesyntax/FileWorkTest.class
diff --git a/jv-read-from-file1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst b/jv-read-from-file1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
deleted file mode 100644
index 51aa4f9b..00000000
--- a/jv-read-from-file1/target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
+++ /dev/null
@@ -1 +0,0 @@
-/Users/mihail/githubprojects/jv-read-from-file1/src/test/java/core/basesyntax/FileWorkTest.java
diff --git a/jv-read-from-file1/target/surefire-reports/TEST-core.basesyntax.FileWorkTest.xml b/jv-read-from-file1/target/surefire-reports/TEST-core.basesyntax.FileWorkTest.xml
deleted file mode 100644
index 0b21a795..00000000
--- a/jv-read-from-file1/target/surefire-reports/TEST-core.basesyntax.FileWorkTest.xml
+++ /dev/null
@@ -1,73 +0,0 @@
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
\ No newline at end of file
diff --git a/jv-read-from-file1/target/surefire-reports/core.basesyntax.FileWorkTest.txt b/jv-read-from-file1/target/surefire-reports/core.basesyntax.FileWorkTest.txt
deleted file mode 100644
index 86dfbe5c..00000000
--- a/jv-read-from-file1/target/surefire-reports/core.basesyntax.FileWorkTest.txt
+++ /dev/null
@@ -1,4 +0,0 @@
--------------------------------------------------------------------------------
-Test set: core.basesyntax.FileWorkTest
--------------------------------------------------------------------------------
-Tests run: 5, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 0.13 sec
diff --git a/jv-read-from-file1/target/test-classes/core/basesyntax/FileWorkTest.class b/jv-read-from-file1/target/test-classes/core/basesyntax/FileWorkTest.class
deleted file mode 100644
index c7cb4fcb8b041521b63462758985403d0368fd0a..0000000000000000000000000000000000000000
GIT binary patch
literal 0
HcmV?d00001
literal 5277
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
-
- 4.0.0
-
- mate-academy
- read-from-file
- 1.0-SNAPSHOT
-
-
- 11
- UTF-8
- UTF-8
- 3.1.1
-
- https://raw.githubusercontent.com/mate-academy/style-guides/master/java/checkstyle.xml
-
-
-
-
-
- junit
- junit
- 4.12
- test
-
-
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
- 3.1.1
-
-
- compile
-
- check
-
-
-
-
- ${maven.checkstyle.plugin.configLocation}
- UTF-8
- true
- true
- false
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
- 3.8.0
-
-
- ${jdk.version}
- ${project.build.sourceEncoding}
-
-
-
-
-
-
diff --git a/jv-read-from-file12/src/main/java/core/basesyntax/FileWork.java b/jv-read-from-file12/src/main/java/core/basesyntax/FileWork.java
deleted file mode 100644
index 7884760f..00000000
--- a/jv-read-from-file12/src/main/java/core/basesyntax/FileWork.java
+++ /dev/null
@@ -1,39 +0,0 @@
-package core.basesyntax;
-
-import java.io.BufferedReader;
-import java.io.FileReader;
-import java.io.IOException;
-import java.util.Arrays;
-
-public class FileWork {
- private static final String SEPARATOR_OF_WORDS = " ";
-
- public String[] readFromFile(String fileName) {
- try {
- BufferedReader reader = new BufferedReader(new FileReader(fileName));
- int value = reader.read();
- StringBuilder builder = new StringBuilder();
- while (value != -1) {
- builder.append((char) value);
- value = reader.read();
- }
- String [] words = builder.toString().toLowerCase().split("\\W+");
- StringBuilder resultBuilder = new StringBuilder();
- for (String word : words) {
- if (word.charAt(0) == 'w') {
- resultBuilder.append(word).append(SEPARATOR_OF_WORDS);
- }
- }
- if (resultBuilder.toString().isEmpty()) {
- return new String[0];
- }
- String [] appropriateWords = resultBuilder.toString().trim().split(SEPARATOR_OF_WORDS);
- Arrays.sort(appropriateWords);
- return appropriateWords;
- } catch (IOException e) {
- throw new RuntimeException("Can't read file " + e);
- } catch (StringIndexOutOfBoundsException e) {
- return new String[0];
- }
- }
-}
diff --git a/jv-read-from-file12/src/test/java/core/basesyntax/FileWorkTest.java b/jv-read-from-file12/src/test/java/core/basesyntax/FileWorkTest.java
deleted file mode 100644
index 2e2f9393..00000000
--- a/jv-read-from-file12/src/test/java/core/basesyntax/FileWorkTest.java
+++ /dev/null
@@ -1,99 +0,0 @@
-package core.basesyntax;
-
-import java.nio.charset.StandardCharsets;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.Arrays;
-import org.junit.Assert;
-import org.junit.BeforeClass;
-import org.junit.Test;
-
-public class FileWorkTest {
- private static final String TEMP_DIRECTORY = System.getProperty("java.io.tmpdir") + "/";
- private static final String EMPTY_FILE_NAME = TEMP_DIRECTORY + "test1";
- private static final String SECOND_FILE_NAME = TEMP_DIRECTORY + "test2";
- private static final String THIRD_FILE_NAME = TEMP_DIRECTORY + "test3";
- private static final String FOURS_FILE_NAME = TEMP_DIRECTORY + "test4";
- private static final String FIFTH_FILE_NAME = TEMP_DIRECTORY + "test5";
-
- private static final String[] EMPTY_ARRAY_RESULT = new String[0];
- private static final String[] RESULT_FROM_LOWER_CASE =
- new String[]{"walk", "warm", "with", "with"};
- private static final String[] RESULT_FROM_CAMEL_CASE =
- new String[]{"wall", "wave", "width", "world", "www"};
- private static final String[] RESULT_FROM_ADJACENT_WORDS_CASE =
- new String[]{"was", "was", "whenever", "which", "which", "worse"};
-
- @BeforeClass
- public static void beforeClass() throws Exception{
- Files.write(Path.of(EMPTY_FILE_NAME), "".getBytes(StandardCharsets.UTF_8));
- Files.write(Path.of(SECOND_FILE_NAME), (
- "Beautiful two-bedroom city flat five minutes' walk from the cathedral.\n" +
- "Fully equipped kitchen, living room with a large sofa and chairs, big TV and balcony.\n" +
- "The balcony has space for four people to sit and gets the sun in the mornings,\n" +
- "and the flat is light and warm. The upstairs bedroom sleeps four people, with two double beds;\n" +
- "the downstairs bedroom sleeps two in single beds.\n" +
- "The flat is perfect for families and is near shops, bars and restaurants.\n").getBytes(StandardCharsets.UTF_8));
- Files.write(Path.of(THIRD_FILE_NAME), (
- "Four-bedroom farmhouse in the countryside. All of the four double bedrooms are en suite.\n" +
- "Farm kitchen, tables and chairs outside. Great for groups of friends. The supermarket is half\n" +
- "an hour by car and you can take a train from the village into the city. Escape from normal life\n" +
- "for a few days.\n").getBytes(StandardCharsets.UTF_8));
- Files.write(Path.of(FOURS_FILE_NAME), (
- "WWW? Four-bedroom farmhouse in the countryside. Wave! All of the four double bedrooms are en suite.\n" +
- "Farm kitchen, tables and chairs outside. Great for groups of friends. World and the supermarket is\n" +
- "half an hour by car and you can take a train from wall the village into the city. Escape from normal\n" +
- "life for a few days, width.\n").getBytes(StandardCharsets.UTF_8));
- Files.write(Path.of(FIFTH_FILE_NAME), (
- "Whenever I have gone there, there have been either so many\n" +
- "people that I have not been able to see the pictures, which\n" +
- "was dreadful, or so many pictures that I have not been able to see the people, which was\n" +
- "worse. The Grosvenor is really the only place.\"\n").getBytes(StandardCharsets.UTF_8));
- }
-
- @Test
- public void readFromEmptyFile() {
- FileWork fileWork = new FileWork();
- String[] actualResult = fileWork.readFromFile(EMPTY_FILE_NAME);
- Assert.assertArrayEquals("Test failed! You should returned empty array.",
- EMPTY_ARRAY_RESULT, actualResult);
- }
-
- @Test
- public void getLowerCaseResultFromFile() {
- FileWork fileWork = new FileWork();
- String[] actualResult = fileWork.readFromFile(SECOND_FILE_NAME);
- Assert.assertArrayEquals("Test failed! You should returned next array "
- + Arrays.toString(RESULT_FROM_LOWER_CASE) + " but you returned "
- + Arrays.toString(actualResult),
- RESULT_FROM_LOWER_CASE, actualResult);
- }
-
- @Test
- public void getCamelCaseResultFromFile() {
- FileWork fileWork = new FileWork();
- String[] actualResult = fileWork.readFromFile(FOURS_FILE_NAME);
- Assert.assertArrayEquals("Test failed! You should returned next array "
- + Arrays.toString(RESULT_FROM_CAMEL_CASE) + " but you returned "
- + Arrays.toString(actualResult),
- RESULT_FROM_CAMEL_CASE, actualResult);
- }
-
- @Test
- public void getEmptyResultFromFile() {
- FileWork fileWork = new FileWork();
- String[] actualResult = fileWork.readFromFile(THIRD_FILE_NAME);
- Assert.assertArrayEquals("Test failed! You should returned empty array.",
- EMPTY_ARRAY_RESULT, actualResult);
- }
-
- @Test
- public void getAdjacentWordsResultFromFile() {
- FileWork fileWork = new FileWork();
- String[] actualResult = fileWork.readFromFile(FIFTH_FILE_NAME);
- Assert.assertArrayEquals("Test failed! You should returned next array "
- + Arrays.toString(RESULT_FROM_ADJACENT_WORDS_CASE) + " but you returned "
- + Arrays.toString(actualResult),
- RESULT_FROM_ADJACENT_WORDS_CASE, actualResult);
- }
-}
diff --git a/jv-read-from-file12/test1 b/jv-read-from-file12/test1
deleted file mode 100644
index e69de29b..00000000
diff --git a/jv-read-from-file12/test2 b/jv-read-from-file12/test2
deleted file mode 100644
index 62ecaf9c..00000000
--- a/jv-read-from-file12/test2
+++ /dev/null
@@ -1,6 +0,0 @@
-Beautiful two-bedroom city flat five minutes' walk from the cathedral.
-Fully equipped kitchen, living room with a large sofa and chairs, big TV and balcony.
-The balcony has space for four people to sit and gets the sun in the mornings,
-and the flat is light and warm. The upstairs bedroom sleeps four people, with two double beds;
-the downstairs bedroom sleeps two in single beds.
-The flat is perfect for families and is near shops, bars and restaurants.
diff --git a/jv-read-from-file12/test3 b/jv-read-from-file12/test3
deleted file mode 100644
index 12c3961f..00000000
--- a/jv-read-from-file12/test3
+++ /dev/null
@@ -1,4 +0,0 @@
-Four-bedroom farmhouse in the countryside. All of the four double bedrooms are en suite.
-Farm kitchen, tables and chairs outside. Great for groups of friends. The supermarket is half
-an hour by car and you can take a train from the village into the city. Escape from normal life
-for a few days.
diff --git a/jv-read-from-file12/test4 b/jv-read-from-file12/test4
deleted file mode 100644
index a5c34f4e..00000000
--- a/jv-read-from-file12/test4
+++ /dev/null
@@ -1,4 +0,0 @@
-WWW? Four-bedroom farmhouse in the countryside. Wave! All of the four double bedrooms are en suite.
-Farm kitchen, tables and chairs outside. Great for groups of friends. World and the supermarket is
-half an hour by car and you can take a train from wall the village into the city. Escape from normal
-life for a few days, width.
diff --git a/jv-read-from-file12/test5 b/jv-read-from-file12/test5
deleted file mode 100644
index 90465912..00000000
--- a/jv-read-from-file12/test5
+++ /dev/null
@@ -1,4 +0,0 @@
-Whenever I have gone there, there have been either so many
-people that I have not been able to see the pictures, which
-was dreadful, or so many pictures that I have not been able to see the people, which was
-worse. The Grosvenor is really the only place."
diff --git a/src/main/java/core/basesyntax/FileWork.java b/src/main/java/core/basesyntax/FileWork.java
index ba2d8396..f111c494 100644
--- a/src/main/java/core/basesyntax/FileWork.java
+++ b/src/main/java/core/basesyntax/FileWork.java
@@ -1,8 +1,39 @@
package core.basesyntax;
+import java.io.BufferedReader;
+import java.io.FileReader;
+import java.io.IOException;
+import java.util.Arrays;
+
public class FileWork {
+ private static final String SEPARATOR_OF_WORDS = " ";
+
public String[] readFromFile(String fileName) {
- //write your code here
- return null;
+ try {
+ BufferedReader reader = new BufferedReader(new FileReader(fileName));
+ int value = reader.read();
+ StringBuilder builder = new StringBuilder();
+ while (value != -1) {
+ builder.append((char) value);
+ value = reader.read();
+ }
+ String[] words = builder.toString().toLowerCase().split("\\W+");
+ StringBuilder resultBuilder = new StringBuilder();
+ for (String word : words) {
+ if (word.charAt(0) == 'w') {
+ resultBuilder.append(word).append(SEPARATOR_OF_WORDS);
+ }
+ }
+ if (resultBuilder.toString().isEmpty()) {
+ return new String[0];
+ }
+ String[] appropriateWords = resultBuilder.toString().trim().split(SEPARATOR_OF_WORDS);
+ Arrays.sort(appropriateWords);
+ return appropriateWords;
+ } catch (IOException e) {
+ throw new RuntimeException("Can't read file " + e);
+ } catch (StringIndexOutOfBoundsException e) {
+ return new String[0];
+ }
}
-}
+}
\ No newline at end of file
From b14b8621d99e8064bf5b15e8c4dbcb68b057db42 Mon Sep 17 00:00:00 2001
From: Misha
Date: Fri, 13 Oct 2023 14:08:05 +0300
Subject: [PATCH 10/10] second try fix one mistake
---
src/main/java/core/basesyntax/FileWork.java | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/src/main/java/core/basesyntax/FileWork.java b/src/main/java/core/basesyntax/FileWork.java
index f111c494..551dc78c 100644
--- a/src/main/java/core/basesyntax/FileWork.java
+++ b/src/main/java/core/basesyntax/FileWork.java
@@ -36,4 +36,4 @@ public String[] readFromFile(String fileName) {
return new String[0];
}
}
-}
\ No newline at end of file
+}