Mercurial > hg > Database > Alice
comparison src/alice/test/codesegment/local/wordcount/SetTask.java @ 241:02783f3699b1
add word count
author | sugi |
---|---|
date | Tue, 16 Apr 2013 15:09:47 +0900 |
parents | |
children | 3bcaf12cf877 |
comparison
equal
deleted
inserted
replaced
240:d9c9076d6b47 | 241:02783f3699b1 |
---|---|
1 package alice.test.codesegment.local.wordcount; | |
2 | |
3 import alice.codesegment.CodeSegment; | |
4 import java.io.*; | |
5 | |
6 public class SetTask extends CodeSegment { | |
7 | |
8 private WordConfig conf; | |
9 | |
10 public SetTask(WordConfig conf) { | |
11 this.conf = conf; | |
12 } | |
13 | |
14 @Override | |
15 public void run() { | |
16 BufferedReader br = null; | |
17 int i = 0; | |
18 try { | |
19 br= new BufferedReader( | |
20 new InputStreamReader( | |
21 new FileInputStream( | |
22 new File(conf.filename) | |
23 ))); | |
24 int size = conf.division * 1024 * 1024; // 16Kbyte | |
25 char[] buf; | |
26 for (;;i++){ | |
27 buf = new char[size]; | |
28 int check = br.read(buf); | |
29 ods.put("array", buf); | |
30 if (check==-1) break; | |
31 new WordCount(); | |
32 } | |
33 new CorrectResult(i); | |
34 } catch (FileNotFoundException e) { | |
35 System.out.println("file not found"); | |
36 System.exit(0); | |
37 } catch (IOException e) { | |
38 e.printStackTrace(); | |
39 } | |
40 | |
41 try { | |
42 br.close(); | |
43 } catch (IOException e) { | |
44 e.printStackTrace(); | |
45 } | |
46 } | |
47 | |
48 } |