Given these two images from twitter.
http://a3.twimg.com/profile_images/130500759/lowres_profilepic.jpg http://a1.twimg.com/profile_images/58079916/lowres_pr
You can use UUID Class in Java to generate anything into UUID from bytes which is unique and you won't be having a problem with file lookup
String url = http://www.google.com; String shortUrl = UUID.nameUUIDFromBytes("http://www.google.com".getBytes()).toString();