TextUtils.StringSplitter splitter = new TextUtils.SimpleStringSplitter('\n');
splitter.setString(tweetMessage);
tweetMessage = "";
for (String s : splitter)
{
Log.v(getClass().getSimpleName(), "Spliter :: "+ s);
tweetMessage +=s;
}
But this shows up the newline characters as Squares how do I get Rid of that
The characters you’re seeing as squares probably aren’t
'\n'('\u000A') characters.If you’re seeing a multiple lines in your output then it’s possible that multiple characters are being used to split the lines. It might be
'\r\n'but it could be something else.Your best bet is to use a debugger to check exactly what the String contains before you split it. Or you could add some debug code like so:
If you see
\u000D \u000Athen your lines are separated by"\r\n". This means you can’t use aSimpleStringSplitterto split the string since that will only split on a single character.If you don’t want to parse the string manually, you could use the
String.split()method: