The exception you see is that I would strongly recommend a) to catch as a specific type, for example. IOException and b) to register or show with a message or stack trace; and c) at least for checking in LogCat, from the point of view of DDMS, if you program using Eclipse, possibly because Android did not detect config.txt you are trying to open. Typically, for simple cases like yours, files that are closed to the application are opened using openFileInput - see the Documentation for details.
Apart from the exception, your read cycle is faulty: you need to initialize an empty line before entering and fill it in while .
String line = ""; while ((line = br.readLine()) != null) {
However, you do not need a loop if you just want to save the first two lines in different variables.
String line = ""; if ((line = br.readLine()) != null) temp1 = line; if ((line = br.readLine()) != null) temp2 = line;
As others have already pointed out, calling readLine consumes a line, so if your config.txt file contains only one line that your code consumes while , then temp1 and temp2 get null because there is no more text to read.
source share