Mercurial > hg > Members > tatsuki > Alice
view src/alice/test/codesegment/local/wordcount/ReadFileTest.java @ 246:6f8236208875
not use MappedByteBuffer
author | sugi |
---|---|
date | Tue, 21 May 2013 16:29:49 +0900 |
parents | |
children |
line wrap: on
line source
package alice.test.codesegment.local.wordcount; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStreamReader; public class ReadFileTest { public static void main(String[] args){ WordConfig conf = new WordConfig(args); BufferedReader br = null; int i = 0; try { br= new BufferedReader( new InputStreamReader( new FileInputStream( new File(conf.filename) ))); int size = 4; // Kbyte Range range = new Range(size); int check = br.read(range.array); for (;check!=-1;i++){ char[] array; array = new char[size]; check = br.read(array); range.nextchar = array[0]; System.out.print(range.array); // ods System.out.println(range.nextchar); range = new Range(array); } System.out.println(i); } catch (FileNotFoundException e) { System.out.println("file was not found"); System.exit(1); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } }