public static String mask(String str)
    {
        if (str != null && str.length() > MASK_REMAIN) {
            char[] chars = str.toCharArray();
            Arrays.fill(chars, 0, chars.length - MASK_REMAIN, '*');
            return new String(chars);
        }
        return str;
    }
@Test
    public void testMask()
    {
        assertNull(mask(null));
        assertEquals("", mask(""));
        assertEquals("123", mask("123"));
        assertEquals("123456", mask("123456"));
        assertEquals("****567890", mask("1234567890"));
    }