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:
for (int u : tweetMessage.toCharArray()) {
Log.v(getClass().getSimpleName(), String.format("\\u%04X",u));
}
If you see \u000D \u000A
then your lines are separated by "\r\n"
. This means you can't use a SimpleStringSplitter
to 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:
for (String s : tweetMessage.split("\r\n") {
//do something with s
}