Dan Harvey
Dan Harvey

Reputation: 798

Android memory error

I cannot understand why this keeps crashing with a memory error:

    server = new URL("http://-link cannot be supplied-");
    BufferedReader reader2 = read(server);
    line = reader2.readLine();
    StringBuilder bigString = new StringBuilder("");
     while(line!=null) {
         bigString.append(line);
         reader2.readLine();
     }

the file is not -that- big 7000 odd lines @ 240,031 bytes on disk.

Basically what i need to do is to tell wether the file contains a small string (a postcode) the file is basically a list of postcodes.

What is the best way to read this in? as obviously what i am doing is not working at all :D

Upvotes: 1

Views: 66

Answers (1)

Guillaume
Guillaume

Reputation: 22822

Your while loop never ends!

while(line!=null) {
     bigString.append(line);
     line = reader2.readLine();
 }

should work.

Upvotes: 3

Related Questions