//split the sentence manually
public static String getSplit(String str){
char[] str_1 = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
StringBuffer sbuffer = new StringBuffer();
for(int i = 0; i<str.length();i++){
for(int j = 0; j<str_1.length; j++){
if(str.charAt(i) == str_1[j]){
sbuffer.append(" ");
}
}
sbuffer.append(str.charAt(i));
}
return sbuffer;
}
//split the sentence using API method
public static String getSplitByMethod(String str){
StringBuffer sbuffer = new StringBuffer();
for(int i = 0;i<str.length();i++){
if(Character.isUpperCase(str.charAt(i))){
sbuffer.append(" ").append(str.charAt(i));
}else{
sbuffer.append(str.charAt(i));
}
}
return sbuffer.toString();
}
public static String getSplit(String str){
char[] str_1 = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
StringBuffer sbuffer = new StringBuffer();
for(int i = 0; i<str.length();i++){
for(int j = 0; j<str_1.length; j++){
if(str.charAt(i) == str_1[j]){
sbuffer.append(" ");
}
}
sbuffer.append(str.charAt(i));
}
return sbuffer;
}
//split the sentence using API method
public static String getSplitByMethod(String str){
StringBuffer sbuffer = new StringBuffer();
for(int i = 0;i<str.length();i++){
if(Character.isUpperCase(str.charAt(i))){
sbuffer.append(" ").append(str.charAt(i));
}else{
sbuffer.append(str.charAt(i));
}
}
return sbuffer.toString();
}
No comments:
Post a Comment