public static String unmask(char charToUnmask,String masked){
  if (charToUnmask == '%' || charToUnmask == '\\') {
    throw new IllegalArgumentException("Parameter charToMask " + charToUnmask + " is not allowed!");
  }
  StringBuilder unmaskedStringBuilder=new StringBuilder();
  char maskChar='%';
  char escapeChar='\\';
  boolean escapeCharFound=false;
  for (  char c : masked.toCharArray()) {
    if (c == maskChar) {
      if (escapeCharFound) {
        unmaskedStringBuilder.append(maskChar);
        escapeCharFound=false;
      }
 else {
        unmaskedStringBuilder.append(charToUnmask);
      }
    }
 else     if (c == escapeChar) {
      if (escapeCharFound) {
        unmaskedStringBuilder.append(escapeChar);
        escapeCharFound=false;
      }
 else {
        escapeCharFound=true;
      }
    }
 else {
      unmaskedStringBuilder.append(c);
    }
  }
  return unmaskedStringBuilder.toString();
}

public static String unmask ( char charToUnmask , String masked ) { if ( charToUnmask == '%' || charToUnmask == '\\' ) { throw new IllegalArgumentException ( "Parameter charToMask " + charToUnmask + " is not allowed!" ) ; } StringBuilder unmaskedStringBuilder = new StringBuilder ( ) ; char maskChar = '%' ; char escapeChar = '\\' ; boolean escapeCharFound = false ; for ( char c : masked . toCharArray ( ) ) { if ( c == maskChar ) { if ( escapeCharFound ) { unmaskedStringBuilder . append ( maskChar ) ; escapeCharFound = false ; } else { unmaskedStringBuilder . append ( charToUnmask ) ; } } else if ( c == escapeChar ) { if ( escapeCharFound ) { unmaskedStringBuilder . append ( escapeChar ) ; escapeCharFound = false ; } else { escapeCharFound = true ; } } else { unmaskedStringBuilder . append ( c ) ; } } return unmaskedStringBuilder . toString ( ) ; }
unmaskes a masked string . examples ( chartounmask = ' | ' ) : < br > hello % mandy = > hello | mandy < br > hel \ \ lo % mandy = > hel \ lo | mandy < br > h \ % l \ \ lo % mandy = > h % l \ lo | mandy < br >
