Удалить пространства в начале и конец струнной Java

String withSpaces = "  Hi  ";
String withoutSpaces = withSpaces.trim();
Determined Dingo