java trim trailing spaces printf code example Example: java printf trailing whitespace System.out.printf("%-20s", str);