public static String ltrim ( String pString ) { if ( ( pString == null ) || ( pString . length ( ) == 0 ) ) { return pString ; // Null or empty string } for ( int i = 0 ; i < pString . length ( ) ; i ++ ) { if ( ! Character . isWhitespace ( pString . charAt ( i ) ) ) { if ( i == 0 ) { return pString ; // First char is not whitespace } else { return pString . substring ( i ) ; // Return rest after whitespace } } } // If all whitespace, return empty string return "" ; }
Trims the argument string for whitespace on the left side only .