Hi all,
I'm fairly new to android. I've been building a very basic SMS
application as a way to get to know the system but I'm having problems
reading a text file back into the app.
The code looks like so:
FileInputStream inFile = openFileInput(SMSFile);
InputStreamReader isr = new InputStreamReader(inFile);
BufferedReader in = new BufferedReader(isr);
String sender = in.readLine();
String time = in.readLine();
StringBuilder bodyBuilder = new StringBuilder();
while(in.readLine() != null)
{
bodyBuilder.append(in.readLine());
bodyBuilder.append("\n");
}
String body = bodyBuilder.toString();
inFile.close();
The file is as follows:
111213141516
1221838163000
this is yet another message
with multiple lines
three this time
The file will always have the number the message came from and the
time (as a UNIX time stamp) on the first and second lines. The number
of lines after that is completely variable.
I've been able to read the number and time back no problem. The
problem I'm having is that by using while(in.readLine() != null) I
lose a line from the buffer. So for this file the String body would
read "with multiple lines \n three this time"
Any input would be greatly appreciated.
Thanks,
V.
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---