on 10-13-2008 8:15 AM
Hi Experts,
I have a string with maximum no of characters as 200,
I want to split this string into two parts with 100 100 characters,
How to do that?
I tried using split() function but i dont how to use it when splitting with no of characters.
Regards
Upendra
Hi,
if String s="sub string";
String s1=s.substring(0,3);
String s2 =s.substring(4,9);
use the above code to split the string s into "sub" and "string".
Regards,
ramesh
Edited by: Ramesh Babu V on Oct 13, 2008 12:52 PM
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi upendra,
You can either of the following code, for spliting and capturing the string.
1.
StringTokenizer st = new StringTokenizer("this is a test");
while (st.hasMoreTokens()) {
wdComponentAPI.getMessageManager().reportSuccess(st.nextToken());
}
2.
class StringSplit {
public static void main(String args[]) throws Exception{
new StringSplit().doit();
}
public void doit() {
String s3 = "Real-How-To";
String [] temp = null;
temp = s3.split("-");
dump(temp);
}
public void dump(String []s) {
wdComponentAPI.getMessageManager().reportSuccess("----
");
for (int i = 0 ; i < s.length ; i++) {
wdComponentAPI.getMessageManager().reportSuccess(s);
}
wdComponentAPI.getMessageManager().reportSuccess("----
");
}
}
Thanks
Anup
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
hi!
you can take two string where you can store the splitted string.
String s1 = str.substring(0, 99);
String s2 = str.substring(100, 199);
thanks
vishal
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
84 | |
25 | |
12 | |
9 | |
6 | |
6 | |
5 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.