View Single Post
Old 08-13-2008, 06:46 AM   #1 (permalink)
New Member
Join Date: Apr 2008
Model: 8830
Carrier: verizon
Posts: 9
Post Thanks: 0
Thanked 0 Times in 0 Posts
Default Reading from a text file

Please Login to Remove!

Ok, there is no way that this is as hard as I'm making it out to be.

my.txt has only one line in it that says "this is the first line".

I have tried reading the docs and writing my own code and I've tried 15 other examples that I've found on the internet and in books, nothing seems to work.

            FileConnection fconn = null;
            InputStream inputStream = null;
            StringBuffer sb = new StringBuffer();

            String filePath = "file:///SDCard/newFolder/my.txt";
                try {
                    fconn = (FileConnection);
                    inputStream = fconn.openInputStream();
                    InputStreamReader isr = new InputStreamReader(inputStream);

            char c;

            while ((c = (char) != -1) {


            return sb.toString();
        } catch(Exception ex) {
            return "problem";


The path is correct, my.txt was created by another piece of code in the program.
Offline   Reply With Quote