开发者

Skipping lines in android java strings

  Giveaway Updates - v1.0.0  ------------------------------------- Application has been created---------------------------------------

I checked the application in the emulator. There is exactly 4 dashes in the same line as giveaway updates in which i wanted to only have giveaway updates there. It looks like this ATM

Giveaway Updates - v1.0.0----
-----------------------------
Application has been created-
-----------------------------

how can i make开发者_如何学运维 it so it would be like this?

Giveaway Updates - v1.0.0
-----------------------------
Application has been created
-----------------------------


You can do something like that:

public String changeFormat(String myString) {
    String[] lines = myString.split("-[-]+"); // split everytime there are two or more '-'
    StringBuffer sb = new StringBuffer(myString.length());
    for (String line in lines) {
        sb.append(line);
        sb.append('\n');
        sb.append("-----------------------------");
        sb.append('\n');
    }
    return sb.toString()
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜