public static String stripString(String string,int beginLength,int endLength){
  if (string == null || string.isEmpty()) {
    return "";
  }
  if (beginLength < 0) {
    beginLength=0;
  }
  if (endLength < 0) {
    endLength=0;
  }
  if (string.length() > beginLength + endLength) {
    return string.substring(0,beginLength) + SEPARATOR + string.substring(string.length() - endLength);
  }
 else {
    return string;
  }
}

public static String stripString ( String string , int beginLength , int endLength ) { if ( string == null || string . isEmpty ( ) ) { return "" ; } if ( beginLength < 0 ) { beginLength = 0 ; } if ( endLength < 0 ) { endLength = 0 ; } if ( string . length ( ) > beginLength + endLength ) { return string . substring ( 0 , beginLength ) + SEPARATOR + string . substring ( string . length ( ) - endLength ) ; } else { return string ; } }
returns stripped string , if input string is too long . examples : stripstring ( " 1234 " , 2 , 2 ) - > 1234 stripstring ( " 1234 " , 2 , 1 ) - > 12 [ . . . ] 4
