code: private static String maskText(String text, int begPos, int endPos)
    {
      // Convert the SQL statement to a char array to obe able to modify it.
      char[] chars = text.toCharArray();
  
      // Mask the value in the SQL statement using *.
      for (int curPos = begPos; curPos < endPos; curPos++)
      {
        chars[curPos] = '☺';
      }
  
      // Convert it back to a string
      return String.valueOf(chars);
    }
docs: Masks given text between begin position and end position.
  
  @param text   text to mask
  @param begPos begin position (inclusive)
  @param endPos end position (exclusive)
  @return masked text