public static String getShortUrl()
{
ByteArrayOutputStream baos = new ByteArrayOutputStream();
DataOutputStream dos = new DataOutputStream(baos);
UUID uuid = UUID.randomUUID();
String shortUrlKey = null;
try
{
dos.writeLong(uuid.getMostSignificantBits());
String encoded = new String(Base64.encodeBase64(baos.toByteArray()), "ISO-8859-1");
shortUrlKey = StringUtils.left(encoded, 5);
String match = "[^\uAC00-\uD7A3xfe0-9a-zA-Z\\s]";
shortUrlKey =shortUrlKey.replaceAll(match, Character.toString(((char)((Math.random() * 26) + 97))) );
}
catch (IOException e) {
e.printStackTrace();
shortUrlKey = null;
}
return shortUrlKey;
}