if java version > 6 should use encoding.isEmpty()