Find Blank and Empty String

Java-Find Blank and Empty String

Find Blank and Empty String The String class provides two methods, isBlank() and isEmpty(), that used to find if the string is empty or blank. The isBlank() method returns true if the string is empty or contains only white space codepoints, otherwise false. The isEmpty() method returns true if, and only if, length() is 0. For examples: … Read more…

String to Bytes

Java-String to Bytes

String to Bytes The getBytes( ) method of String is used to encode the string into a sequence of bytes using the platform’s default charset(UTF-8) and store the result into a new byte array. For example: Another Forms of getBytes Method Other forms of getBytes() are also available. These are: These methods are used to encode … Read more…

Strip

Java-Strip

Strip The strip( ) method of String is used to remove the leading and trailing white spaces in the string . For example: StripLeading The stripLeading( ) method of String is used to remove the leading white spaces in the string. For example: StripTrailing The stripTrailing( ) method of String is used to remove the trailing white … Read more…

Split

Java-Split

Split The split() method of String is used to split the string around matches of the given regular expression. It has the following form: The array returned by this method contains each substring of this string that is terminated by another substring that matches the given expression or is terminated by the end of the string. … Read more…

Adjust Indentation

Java-Adjust Indentation

Adjust Indentation The intent( ) method of Stirng is used to adjust the indentation of each line of this string based on the specified value, and normalizes line termination characters. If value is 5 then 5 spaces (U+0020) are inserted at the beginning of each line. For example: If value is -5 then up to … Read more…

Collectors toMap

Java-Collectors toMap

Collectors toMap The Collectors class provides a large number of static methods for common collectors. The toMap( ) method of the collectors is used to collect stream elements into a Map.  The toMap( ) method has three forms. The first is: If the mapped keys contain duplicates (according to Object.equals(Object)), an IllegalStateException is thrown when the collection … Read more…