Mercurial > hg > pub > prymula > com
comparison kopieckreta/src/MyResource.java @ 0:2787f5e749ae
INIT
author | prymula <prymula76@outlook.com> |
---|---|
date | Thu, 21 Sep 2023 22:33:57 +0200 |
parents | |
children | 489244127359 |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:2787f5e749ae |
---|---|
1 /* | |
2 Nie mieszać z java.awt.* (!!!) | |
3 */ | |
4 package src; | |
5 | |
6 import java.io.IOException; | |
7 import java.io.InputStream; | |
8 import java.io.PrintStream; | |
9 import java.io.BufferedReader; | |
10 import java.io.InputStreamReader; | |
11 | |
12 import java.util.*; | |
13 import java.lang.*; | |
14 | |
15 | |
16 class MyResource { | |
17 final int MAX_WORDS=67656; | |
18 | |
19 public void MyResource() | |
20 { | |
21 } | |
22 private static final String absName = "/slownik.txt"; | |
23 // TODO - to jest mniej eleganckie; | |
24 static ArrayList<String> directory3 = new ArrayList<String>(); | |
25 static ArrayList<String> directory4 = new ArrayList<String>(); | |
26 static ArrayList<String> directory5 = new ArrayList<String>(); | |
27 static ArrayList<String> directory6 = new ArrayList<String>(); | |
28 static ArrayList<String> directory7 = new ArrayList<String>(); | |
29 static ArrayList<String> directory8 = new ArrayList<String>(); | |
30 static ArrayList<String> directory9 = new ArrayList<String>(); | |
31 static ArrayList<String> directory10 = new ArrayList<String>(); | |
32 static ArrayList<String> directory11 = new ArrayList<String>(); | |
33 static ArrayList<String> directory12 = new ArrayList<String>(); | |
34 static ArrayList<String> directory13 = new ArrayList<String>(); | |
35 static ArrayList<String> directory14 = new ArrayList<String>(); | |
36 //static int mem=0; | |
37 | |
38 public void read() throws Exception{ | |
39 String list; | |
40 | |
41 try { | |
42 InputStream is = this.getClass().getResourceAsStream(absName); | |
43 BufferedReader br=new BufferedReader(new InputStreamReader(is, "utf-8")); | |
44 for (int i=0; i<MAX_WORDS; i++){ | |
45 list = br.readLine(); | |
46 | |
47 if (list.length()==3){ | |
48 directory3.add(list); | |
49 } | |
50 else if (list.length()==4){ | |
51 directory4.add(list); | |
52 } | |
53 else if (list.length()==5){ | |
54 directory5.add(list); | |
55 } | |
56 else if (list.length()==6){ | |
57 directory6.add(list); | |
58 } | |
59 else if (list.length()==7){ | |
60 directory7.add(list); | |
61 } | |
62 else if (list.length()==8){ | |
63 directory8.add(list); | |
64 } | |
65 else if (list.length()==9){ | |
66 directory9.add(list); | |
67 } | |
68 else if (list.length()==10){ | |
69 directory10.add(list); | |
70 } | |
71 else if (list.length()==11){ | |
72 directory11.add(list); | |
73 } | |
74 else if (list.length()==12){ | |
75 directory12.add(list); | |
76 } | |
77 else if (list.length()==13){ | |
78 directory13.add(list); | |
79 } | |
80 else if (list.length()==14){ | |
81 directory14.add(list); | |
82 } | |
83 } | |
84 | |
85 } | |
86 catch (Exception e){ | |
87 e.printStackTrace(); | |
88 } | |
89 } | |
90 static public String getDirectory(int n_dir){ | |
91 Random generator = new Random(); | |
92 //mem++; | |
93 if (n_dir==3){ | |
94 return (directory3.get(generator.nextInt(directory3.size()))); | |
95 } | |
96 if (n_dir==4){ | |
97 return (directory4.get(generator.nextInt(directory4.size()))); | |
98 } | |
99 if (n_dir==5){ | |
100 return (directory5.get(generator.nextInt(directory5.size()))); | |
101 } | |
102 if (n_dir==6){ | |
103 return (directory6.get(generator.nextInt(directory6.size()))); | |
104 } | |
105 if (n_dir==7){ | |
106 return (directory7.get(generator.nextInt(directory7.size()))); | |
107 } | |
108 if (n_dir==8){ | |
109 return (directory8.get(generator.nextInt(directory8.size()))); | |
110 } | |
111 if (n_dir==9){ | |
112 return (directory9.get(generator.nextInt(directory9.size()))); | |
113 } | |
114 if (n_dir==10){ | |
115 return (directory10.get(generator.nextInt(directory10.size()))); | |
116 } | |
117 if (n_dir==11){ | |
118 return (directory11.get(generator.nextInt(directory11.size()))); | |
119 } | |
120 if (n_dir==12){ | |
121 return (directory12.get(generator.nextInt(directory12.size()))); | |
122 } | |
123 if (n_dir==13){ | |
124 return (directory13.get(generator.nextInt(directory13.size()))); | |
125 } | |
126 if (n_dir==14){ | |
127 return (directory14.get(generator.nextInt(directory14.size()))); | |
128 } | |
129 // Na sztukę | |
130 return ""; | |
131 } | |
132 } |