The
withKeyValueSeparator(char separator) method of Guava's
Splitter Class accepts a mandatory parameter
separator and splits entries into keys and values using this separator.
Syntax:
public Splitter.MapSplitter withKeyValueSeparator(char separator)
Parameters: The method accepts a parameter
separator and splits entries into keys and values using this separator.
Return Value: The method returns a
MapSplitter which splits entries based on this splitter.
Note: We pass the separator within pairs to this method. The on() method receives the separator between pairs of keys and values.
Below examples illustrate the implementation of withKeyValueSeparator() method of Guava's Splitter class:
Example 1:
Output:
Data Structures -> Coding
Sports -> Football
Capital -> Delhi
Example 2: