如何根据长度拆分字符串并将每个值分配给唯一变量

时间:2019-02-03 07:41:25

标签: java

我从上游得到了一个不确定长度的变量。当我发送到下游时,我必须将其划分为20个字符的长度,我应该为每个变量分配一个变量,最后将整个数据发送为字符串。

例如考虑以下数据。

String source="Under the banner of 'Jan Andolan Satyagraha', the social activist launched his indefinite hunger strike on January 30 at his native village Ralegan-Siddhi to demand the setting up of a Lokpal at the Centre and Lokayuktas in the states as the Prime Minister Narendra Modi-led government";

我应该按如下所述进行转换。

string1 = "Under the banner of ";
string2="'Jan Andolan Satyagr";
string3 = "aha', the social act";

以此类推。

请帮助我实现相同目标。非常感谢。

0 个答案:

没有答案