Now  i hava a txt reader, this program can read more than 5M file!

The software will be released !
U  can get more information from this :
http://51gphone.cn/thread-464-1-1.html

and the software will open source ,  we hope more people join us


2008/12/10 Mark Murphy <[EMAIL PROTECTED]>

>
> yakebao wrote:
> > I have a txt file named "codecs", size is 3M, under the directory "res/
> > raw/".
> >
> > This file has been splited to 25 files by the first character of each
> > line, such as "codecs_a, codecs_b, codecs_c, ......, codecs_y".
> > And,each of the files contents are sorted by the first colum (ASC).
> >
> > Now,  I use the folowing code to read the file content.
> > InputStream is = Resources. openRawResource(R.raw.codecs_a);
> > InputStreamReader isr = new InputStreamReader(is , Charset.forName
> > ("UTF-8"));
> > BufferedReader br = new BufferedReader(isr );
> > ....
> > br.readLine(); //get file content line by line
> > ....
> >
> > In this method , when I input a number(the first column of the file
> > content), I can access the content . But it is so slow.......
>
> That is not surprising.
>
> >
> > For example:
> > Contents of file "codecs_a" :
> >
> ----------------------------------------------------------------------------------------------------
> > COLUMN 1               COLUMN 2                         COLUMN 3
> >
> ----------------------------------------------------------------------------------------------------
> > 1                              This is the first line.
> > DataData
> > 2                              Android Developers
> > technology
> > .......................
> >
> > 10254525                  developers get started         developing
> >
> ----------------------------------------------------------------------------------------------------
> >
> > When I input 1 or 2, search speed is fast , but when I input 10254525,
> > it's so long time to wait for search result.
>
> Again, that is not surprising. Reading in ten million lines, one at a
> time, is going to be bad on any platform, let alone a mobile device.
>
> > Is there any way to improve this program?
>
> Probably several. However, since we have no context for what it is you
> are trying to build, it is very difficult to provide much advice.
>
> Long-term, I recommend you spend some time with a good data algorithms
> book, such as the works of Robert Sedgewick.
>
> --
> Mark Murphy (a Commons Guy)
> http://commonsware.com
> _The Busy Coder's Guide to Android Development_ Version 1.9 Published!
>
> >
>


-- 
Welcome to my site about GPhone:
http://51gphone.cn
I am a GFans!!欢迎你来到我的GPhone网站!!http://51gphone.cn

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to