Skip to content

Commit

Permalink
v8
Browse files Browse the repository at this point in the history
  • Loading branch information
PiotrHic committed Dec 23, 2024
1 parent 15996fe commit bb1b8c5
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions src/main/java/core/basesyntax/FileWork.java
Original file line number Diff line number Diff line change
@@ -1,24 +1,27 @@
package core.basesyntax;

import java.io.*;
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.*;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class FileWork {

public String[] readFromFile(String fileName) {

List<String> result;
try {
result = Files.readAllLines(Paths.get(fileName));
result = Files.readAllLines( Paths.get(fileName));
} catch (IOException e) {
throw new RuntimeException(e);
}

List<String> sortedResult = new ArrayList<>();
List<String> sortedResult = new ArrayList<> ();
for (String s : result) {
sortedResult.addAll(Arrays.stream(s.split("\\W+"))
sortedResult.addAll( Arrays.stream(s.split("\\W+"))
.map(String::toLowerCase)
.filter(word -> word.startsWith("w"))
.toList());
Expand Down

0 comments on commit bb1b8c5

Please sign in to comment.