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…

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…