public String trimChar(String str,final char ch){
  Boolean b=true, e=true;
  str=str.trim();
  while (str.length() > 0 && (b || e)) {
    if (str.charAt(0) == ch)     str=str.substring(1,str.length());
 else     b=false;
    if (str.charAt(str.length() - 1) == ch)     str=str.substring(0,str.length() - 1);
 else     e=false;
  }
  return str;
}

public String trimChar ( String str , final char ch ) { Boolean b = true , e = true ; str = str . trim ( ) ; while ( str . length ( ) > 0 && ( b || e ) ) { if ( str . charAt ( 0 ) == ch ) str = str . substring ( 1 , str . length ( ) ) ; else b = false ; if ( str . charAt ( str . length ( ) - 1 ) == ch ) str = str . substring ( 0 , str . length ( ) - 1 ) ; else e = false ; } return str ; }
this function trims ch in string
