There seems to be no function in Java for splitting and connecting strings, I wrote a
1 Public classlierstring{2 //------------------------------------------------------------------------3 //accepts a string containing a space and returns an array of strings4 Public Staticstring[] Tosarr (String Arg) {5 //System.out.println ("Enter function STRTOASRR");6arg+= "";7 Char[] p=Arg.tochararray ();8String[] Strs=NewString[50];9 Ten intStri=0; One intJ=-1; A for(inti=0;i<p.length;) { - if(p[i]== "){ - if(i-j>1){ theStrs[stri]=arg.substring (j+1, i); -stri++; -j=i; - //System.out.println (strs[stri-1]); + } - Else +j=i; A } ati++; - - } -String[] Atrs=NewString[stri]; - for(inti=0;i<stri;i++){ - inatrs[i]=Strs[i]; - } to //System.out.println (stri); + returnATRs; - the } * //------------------------------------------------------------------------ $ //takes an array of strings, returns a string, joins all the strings in the string array, splits them with spacesPanax Notoginseng Public StaticString Linkarr (string[] x,intIintj) { - if(i>j) the return NULL; + if(j>=x.length) A return NULL; theString a= ""; +StringBuffer SB =NewStringBuffer (); - for(intp=i;p<=j;p++){ $ sb.append (x[p]); $ Sb.append (a); - } - returnsb.tostring (); the } - Public StaticString Linkarr (string[] x,inti) {Wuyi returnLinkarr (x,i,x.length-1); the } - Public StaticString Linkarr (string[] x) { Wu returnLinkarr (x,0); - } About}
Java string splitting and string joins