elegant elegant - 1 year ago 94
Android Question

Replace semi colon (;) character in java

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);

Log.i(TAG, "START *************************************"+outputString);

Log.i(TAG, "************************************* END"+outputString);
if(!outputString.endsWith(";") && !outputString.startsWith(";")){
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??

Answer Source

Your code is working fine you just follow a simple step:

String outputString=inputString.trim();
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download