Advertisement
Guest User

Untitled

a guest
Nov 22nd, 2019
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.13 KB | None | 0 0
  1. package it.akademy;
  2.  
  3. import org.w3c.dom.ls.LSOutput;
  4.  
  5. import java.io.File;
  6. import java.io.FileNotFoundException;
  7. import java.util.*;
  8.  
  9. public class Dictionnary {
  10. static ArrayList<String> allWords = new ArrayList<>();
  11. public static void main(String[] args) {
  12. HashMap<String, ArrayList<String>> map = new HashMap<>();
  13.  
  14. try {
  15. Scanner input = new Scanner(new File("/usr/share/myspell/dicts/fr_FR.dic"));
  16. while (input.hasNext()) {
  17. String word = input.next();
  18. parseWord(word);
  19. }
  20. } catch (FileNotFoundException e) {
  21. e.printStackTrace();
  22. }
  23. makeHashMap("ele");
  24. }
  25.  
  26. private static void parseWord(String line) {
  27. System.out.println(line);
  28. String word = line.substring(0,line.indexOf("/")).toLowerCase();
  29. System.out.println(word);
  30. Dictionnary.allWords.add(word);
  31. }
  32.  
  33. final static int P = 3;
  34. private static void makeHashMap(String S) {
  35. Dictionnary.allWords.stream().filter(element -> element.startsWith(S)).forEach(System.out::println);
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement