Remova os espaços no início e no final da string java
String withSpaces = " Hi ";
String withoutSpaces = withSpaces.trim();
Determined Dingo
String withSpaces = " Hi ";
String withoutSpaces = withSpaces.trim();