package tehtevoog; import java.io.IOException; import java.nio.charset.Charset; import java.nio.file.Files; import java.nio.file.Paths; import java.util.stream.Collectors; import java.util.stream.Stream; public class Proov1 { public static void main(String[] args) throws IOException{ System.out.println(Files.lines(Paths.get("eesnimed.txt") ).filter(s->s.length()==4).map(String::toUpperCase).distinct() .sorted().collect(Collectors.toList())); Stream voog1=Files.lines(Paths.get("eesnimed.txt") ).filter(s->s.length()==4).map(String::toUpperCase).distinct(); if(1>2){voog1=voog1.sorted();} voog1.forEach(System.out::println); //voog1.forEach(System.out::println); Files.write(Paths.get("vastus.txt"), Files.lines(Paths.get("eesnimed.txt") ).filter(s->s.length()==4).map(String::toUpperCase).distinct() .sorted().collect(Collectors.toList()), Charset.defaultCharset()); } }