dream3323
2017-01-30 17:11
浏览 672

如何在Android Studio上将非常长的字符串拆分为多个字符串? [重复]

This question already has an answer here:

Hello i wanna split a very long string ( +10000 character) to multiple String.

I found there is a way with split() but i don't have space " " to split it.

I have only letter. Can i use a loop to split it?

For Example: it 's possible to split the string to multiple strings with 200 character for each one.

</div>

图片转代码服务由CSDN问答提供 功能建议

此问题已经存在 这里有一个答案:

  • 将字符串拆分为Java中相等长度的子字符串 20 answers < / span>

    您好我想将一个非常长的字符串(+10000个字符)拆分为多个字符串 。

    我发现 split()有一种方法,但我没有空格“”来拆分它。 / p>

    我只有信。 我可以使用循环来分割它吗?

    例如:可以将字符串拆分为多个字符串,每个字符串为200个字符。

  • 写回答
  • 关注问题
  • 收藏
  • 邀请回答

1条回答 默认 最新

  • dongzhuifeng1843 2017-01-30 17:46
    已采纳

    As solved by this link, you can use Regex to achieve your requirement

    try

    System.out.println(Arrays.toString(
        "Thequickbrownfoxjumps".split("(?<=\\G.{4})")
    ));
    
    打赏 评论