Didn't think about stringbuilder when I did it. But I'll try it!

Does anyone else have any suggestions about size limitations?

//André

On Feb 9, 8:16 pm, Kostya Vasilyev <kmans...@gmail.com> wrote:
> Can't speak for size limitations, but why are putting the data into a
> vector, and appending to EditText one line at a time?
>
> Reading line by line and building the content in a StringBuilder seems
> more efficient, then you can do editText.setText() just once.
>
> And reading one line at a time is only necessary if your file comes from
> Windows and contains '\r' characters (they are not recognized by
> TextView and have to be stripped, leaving just '\n'-s).
>
> -- Kostya
>
> 09.02.2011 21:20, André пишет:
>
>
>
>
>
>
>
>
>
> > What would be the best way of reading large text files from the
> > sdcard?
>
> > Right now I'm using this in my browser activity:
>
> > File f = new File(filePath);
> > FileInputStream file = new FileInputStream(f);
> > BufferedReader in = new BufferedReader(new InputStreamReader(file));
> > do {
> >    st = in.readLine();
> >    vector.add(st);
> > } while (st != null);
> > in.close();
>
> > and in the other activity where I want to edit the file I have:
>
> > char lf = 10;
> > int k = 0;
> > String s = null;
> > for (int i = 0; i<  browseractivity.vector.size(); i++) {
> >    s = browseractivity.vector.get(k);
> >    if (s != null) {
> >            editText.append(s);
> >            editText.append(String.valueOf(lf));
> >    }
> >    k++;
> > }
>
> > When trying this on a file of 24648 bytes which corresponds to 24097
> > chars on 555 lines
> > I looked in Notepad++ at which characters it cuts.
> > It displays 8764 characters which corresponds exactly to 9000 bytes
> > and 237 lines
>
> > Does any one have a better suggestion of how to do this so I can read
> > larger files?
>
> > //André
>
> --
> Kostya Vasilyev -- WiFi Manager + pretty widget 
> --http://kmansoft.wordpress.com

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

Reply via email to