String str = " Hello World"; str = StringUtil.trimStart(str); System.out.println(str); // Output: "Hello World"
String str = " Good morning"; if (!Character.isWhitespace(str.charAt(0))) { // The string starts with a non-whitespace character // Do something here... } else { // The string starts with a whitespace character // Do something else here... }
ListIn conclusion, the StringUtil class with the trimStart method is included in the com.intellij.openapi.util.text package of the IntelliJ IDEA library.myList = Arrays.asList(" Apple", " Pear", "Grapefruit ", " Banana"); for (int i = 0; i < myList.size(); i++) { String str = myList.get(i); str = StringUtil.trimStart(str); myList.set(i, str); } System.out.println(myList); // Output: ["Apple", "Pear", "Grapefruit ", "Banana"]