I am trying to truncate semi colon from both the ends of a string using this method:
private String truncateSemicolon(String inputString){
String outputString=inputString;
boolean isTruncated = false;
Log.i(TAG, "*************I N P U T T O T R U N C A T E ************* "+outputString);
while(!isTruncated){
if(outputString.startsWith(";")){
outputString=outputString.substring(1,outputString.length());
Log.i(TAG, "START *************************************"+outputString);
}
if(outputString.endsWith(";")){
outputString=outputString.substring(0,(outputString.length()-1));
Log.i(TAG, "************************************* END"+outputString);
}
if(!outputString.endsWith(";") && !outputString.startsWith(";")){
isTruncated=true;
}
}
Log.i(TAG, "*************O U T P U T T O T R U N C A T E ************* "+outputString);
return outputString;
}
But this truncates from beginning only.
What is the problem??