Java: How to split a string by a number of characters?

前端 未结 11 1447
夕颜
夕颜 2020-11-27 06:59

I tried to search online to solve this question but I didn\'t found anything.

I wrote the following abstract code to explain what I\'m asking:

String         


        
11条回答
  •  萌比男神i
    2020-11-27 07:19

    Using Guava:

    Iterable result = Splitter.fixedLength(4).split("how are you?");
    String[] parts = Iterables.toArray(result, String.class);
    

提交回复
热议问题