• R/O
  • SSH
  • HTTPS

wccftb: Commit


Commit MetaInfo

Revision21 (tree)
Time2018-06-08 16:38:04
Authorfenrir_wolf

Log Message

ソース整理

Change Summary

Incremental Difference

--- src/in/lapin/fenrir/WCCF/MainControl.java (revision 20)
+++ src/in/lapin/fenrir/WCCF/MainControl.java (revision 21)
@@ -139,70 +139,29 @@
139139 BufferedReader br;
140140
141141 if(all == null) {
142- all = new ArrayList<Player>();
143-
144- path = Paths.get("wccf_data.csv", new String[0]);
145-
146- br = Files.newBufferedReader(path, Charset.forName("UTF-8"));
147- br.readLine();
148-
149- br.lines().forEach(buffer -> all.add(splitData(buffer)));
150- br.close();
142+ all = readFile("wccf_data.csv");
151143 }
152144 if(team == null) {
153145 team = new ArrayList<Player>();
154146 }
155147 if(teamkp == null) {
156- teamkp = new ArrayList<String[]>();
157-
158- path = Paths.get("teamkp.csv", new String[0]);
159-
160- br = Files.newBufferedReader(path, Charset.forName("UTF-8"));
161-
162- br.lines().forEach(buffer -> teamkp.add(buffer.split(",")));
163- br.close();
148+ teamkp = readFile2("teamkp.csv");
164149 }
165150 if(nationalkp == null) {
166- nationalkp = new ArrayList<String[]>();
167-
168- path = Paths.get("nationalkp.csv", new String[0]);
169-
170- br = Files.newBufferedReader(path, Charset.forName("UTF-8"));
171-
172- br.lines().forEach(buffer -> nationalkp.add(buffer.split(",")));
173- br.close();
151+ nationalkp = readFile2("nationalkp.csv");
174152 }
175153 if(combikp == null) {
176- combikp = new ArrayList<String[]>();
177-
178- path = Paths.get("combikp.csv", new String[0]);
179-
180- br = Files.newBufferedReader(path, Charset.forName("UTF-8"));
181-
182- br.lines().forEach(buffer -> combikp.add(buffer.split(",")));
183- br.close();
154+ combikp = readFile2("combikp.csv");
184155 }
185156 if(rarekp == null) {
186- rarekp = new ArrayList<String[]>();
187-
188- path = Paths.get("rarekp.csv", new String[0]);
189-
190- br = Files.newBufferedReader(path, Charset.forName("UTF-8"));
191-
192- br.lines().forEach(buffer -> rarekp.add(buffer.split(",")));
193- br.close();
157+ rarekp = readFile2("rarekp.csv");
194158 }
195159 if(kpinfo == null) {
196- kpinfo = new ArrayList<String[]>();
197-
198- path = Paths.get("kpinfo.csv", new String[0]);
199-
200- br = Files.newBufferedReader(path, Charset.forName("UTF-8"));
201-
202- br.lines().forEach(buffer -> kpinfo.add(buffer.split(",")));
203- br.close();
160+ kpinfo = readFile2("kpinfo.csv");
204161 }
205-
162+ if(have == null) {
163+ have = readFile("own.lst");
164+ }
206165 if(FW_BA == null) {
207166 path = Paths.get("color.inf", new String[0]);
208167
@@ -215,19 +174,6 @@
215174 br.close();
216175 }
217176
218- if(have == null) {
219- have = new ArrayList<Player>();
220-
221- path = Paths.get("own.lst", new String[0]);
222-
223- if(path.toFile().exists()) {
224- br = Files.newBufferedReader(path, Charset.forName("UTF-8"));
225-
226- br.lines().forEach(buffer -> have.add(getListPlayer(splitData(buffer))));
227- br.close();
228- }
229- }
230-
231177 if (logger == null) {
232178 deleteDirectory("wccftb.log");
233179 //singleton
@@ -239,6 +185,45 @@
239185 }
240186 }
241187
188+ private List<Player> readFile(String fname) throws Exception {
189+
190+ Path path;
191+ BufferedReader br;
192+
193+ List<Player> lst = new ArrayList<Player>();
194+
195+ path = Paths.get(fname, new String[0]);
196+
197+ if (path.toFile().exists()) {
198+ br = Files.newBufferedReader(path, Charset.forName("UTF-8"));
199+ br.readLine();
200+
201+ br.lines().forEach(buffer -> lst.add(splitData(buffer)));
202+ br.close();
203+ }
204+
205+ return lst;
206+ }
207+
208+ private List<String[]> readFile2(String fname) throws Exception {
209+
210+ Path path;
211+ BufferedReader br;
212+
213+ List<String[]> lst = new ArrayList<String[]>();
214+
215+ path = Paths.get(fname, new String[0]);
216+
217+ if (path.toFile().exists()) {
218+ br = Files.newBufferedReader(path, Charset.forName("UTF-8"));
219+
220+ br.lines().forEach(buffer -> lst.add(buffer.split(",")));
221+ br.close();
222+ }
223+
224+ return lst;
225+ }
226+
242227 public Logger getLogger() {
243228 return logger;
244229 }
Show on old repository browser