"also, i would add that if you want this to work with all kinds of characters (accented, etc.), replace getBytes() with getBytes(UTF8) and new String(something) with new String(something, UTF8)" . . . .