语音转换截取90个字以逗号隔开变成小句,多出来以少于90个字的最后一个逗号结束
//按90截句转换
public String[] fromjson90(String url) throws Exception {
List<String> list = new ArrayList<String>();
String[] changeContext =null;
if (null != url && !"".equals(url)) {
String contextparm = url;
int pos =0;
int nextstartindex=0;
String tmpcp = contextparm;
tmpcp = contextparm.substring(nextstartindex, 90+nextstartindex);
while(tmpcp.length() >= 90)
{
pos = find_pos_lastindexof_from_90(tmpcp);
nextstartindex+=pos;
//changeContext[i++]=tmpcp.substring(0, pos);
list.add(tmpcp.substring(0, pos));
int len = contextparm.length();
int end =90+nextstartindex;
if(len <=end ){
tmpcp = contextparm.substring(nextstartindex, len);
}
else{
tmpcp = contextparm.substring(nextstartindex, end);
}
}
list.add(tmpcp);
//changeContext[i++]=tmpcp;
String[] s = new String[list.size()];
changeContext = list.toArray(s);
return changeContext;
}
return changeContext;
}
public int find_pos_lastindexof_from_90(String str90)
{
int lastpos;
lastpos = str90.lastIndexOf(",");
if( lastpos == -1){
lastpos = str90.length();
}
return lastpos;
}
总结不好多多担待,文章只单纯个人总结,如不好勿喷,技术有限,有错漏麻烦指正提出。本人QQ:373965070