public static byte[] escape(final byte[] bytes){
  final byte[] temp=new byte[2 * bytes.length];
  int currentPosition=0;
  for (  final byte b : bytes) {
    if (b == ESCAPE_CHAR) {
      temp[currentPosition++]=ESCAPE_CHAR;
      temp[currentPosition++]=REPLACEMENT_CHAR;
    }
 else     if (b == DELIMITER) {
      temp[currentPosition++]=ESCAPE_CHAR;
      temp[currentPosition++]=ESCAPE_CHAR;
    }
 else {
      temp[currentPosition++]=b;
    }
  }
  final byte[] escaped=new byte[currentPosition];
  System.arraycopy(temp,0,escaped,0,currentPosition);
  return escaped;
}

public static byte [ ] escape ( final byte [ ] bytes ) { final byte [ ] temp = new byte [ 2 * bytes . length ] ; int currentPosition = 0 ; for ( final byte b : bytes ) { if ( b == ESCAPE_CHAR ) { temp [ currentPosition ++ ] = ESCAPE_CHAR ; temp [ currentPosition ++ ] = REPLACEMENT_CHAR ; } else if ( b == DELIMITER ) { temp [ currentPosition ++ ] = ESCAPE_CHAR ; temp [ currentPosition ++ ] = ESCAPE_CHAR ; } else { temp [ currentPosition ++ ] = b ; } } final byte [ ] escaped = new byte [ currentPosition ] ; System . arraycopy ( temp , 0 , escaped , 0 , currentPosition ) ; return escaped ; }
escapes the provided string so that it no longer contains the constants . delimiter character .
