-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFlat.java
More file actions
29 lines (27 loc) · 905 Bytes
/
Flat.java
File metadata and controls
29 lines (27 loc) · 905 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
// LDI-FlatMap/Flat.java
//taha burak sahin pjatk
import java.io.IOException;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Comparator;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import static java.nio.charset.StandardCharsets.UTF_8;
public class Flat {
public static void main(String[] args) {
String result = null;
try (Stream<String> stream =
Files.lines(Paths.get("Flat.java"),UTF_8))
{
result =
stream
.flatMap(l -> Stream.of(l.split("\\P{L}+")))
.filter(w -> w.length() > 9)
.distinct()
.sorted(Comparator.comparing(
String::length).reversed())
.collect(Collectors.joining(", "));
} catch(IOException ignore) { }
System.out.println(result);
}
}