Mercurial > hg > Database > Alice
comparison src/main/java/alice/test/codesegment/local/wordcount/ReadFileTest.java @ 345:8f71c3e6f11d
Change directory structure Maven standard
author | sugi |
---|---|
date | Wed, 16 Apr 2014 18:26:07 +0900 |
parents | |
children | aefbe41fcf12 |
comparison
equal
deleted
inserted
replaced
344:9f97ec18f8c5 | 345:8f71c3e6f11d |
---|---|
1 package alice.test.codesegment.local.wordcount; | |
2 | |
3 import java.io.BufferedReader; | |
4 import java.io.File; | |
5 import java.io.FileInputStream; | |
6 import java.io.FileNotFoundException; | |
7 import java.io.IOException; | |
8 import java.io.InputStreamReader; | |
9 | |
10 public class ReadFileTest { | |
11 | |
12 public static void main(String[] args){ | |
13 WordConfig conf = new WordConfig(args); | |
14 BufferedReader br = null; | |
15 int i = 0; | |
16 try { | |
17 br= new BufferedReader( | |
18 new InputStreamReader( | |
19 new FileInputStream( | |
20 new File(conf.filename) | |
21 ))); | |
22 int size = 4; // Kbyte | |
23 | |
24 Range range = new Range(size); | |
25 int check = br.read(range.array); | |
26 for (;check!=-1;i++){ | |
27 | |
28 char[] array; | |
29 array = new char[size]; | |
30 check = br.read(array); | |
31 range.nextchar = array[0]; | |
32 System.out.print(range.array); // ods | |
33 System.out.println(range.nextchar); | |
34 range = new Range(array); | |
35 } | |
36 System.out.println(i); | |
37 } catch (FileNotFoundException e) { | |
38 System.out.println("file was not found"); | |
39 System.exit(1); | |
40 } catch (IOException e) { | |
41 // TODO Auto-generated catch block | |
42 e.printStackTrace(); | |
43 } | |
44 | |
45 } | |
46 } |