MyClass.java
 

public class MyClass {
  public static void main(String[] args) {
    String myStr = "       Hello World!        ";
    System.out.println(myStr);
    System.out.println(myStr.trim());
  }
}

Result:
       Hello World!       
Hello World!