You can collect the entries into a single String as follows:

  String sorted =
        map.entrySet().stream()
           .sorted(Collections.reverseOrder(Map.Entry.comparingByValue()))
           .map(e-> e.getKey().toString() + "=" + e.getValue().toString())
           .collect(Collectors.joining (","));
Answer from Eran on Stack Overflow
🌐
Coderwall
coderwall.com › p › im4lja › joining-objects-into-a-string-with-java-8-stream-api
Joining Objects into a String with Java 8 Stream API (Example)
July 17, 2023 - #string · #java · #join · #stream · You can leverage Java 8 Collectors to concatenate some objects into a string separated by a delimiter: For example: List<Integer> numbers = Arrays.asList( 4, 8, 15, 16, 23, 42 ); return numbers.stream() ...
🌐
DigitalOcean
digitalocean.com › community › tutorials › java-stream-collect-method-examples
Java Stream collect() Method Examples | DigitalOcean
Technical tutorials, Q&A, events — This is an inclusive place where developers can find or lend support and discover new ways to contribute to the community.
🌐
W3docs
w3docs.com › home › code snippets › java › using streams to convert a list of objects into a string obtained from the tostring method
Using streams to convert a list of objects into a string obtained from the toString method | W3docs
java · streams · map · collect · reduce · You can use the map and collect methods of the Stream class to achieve this. Here is an example: List<Object> list = ... String result = list.stream().map(Object::toString).collect(Collectors.joining(", ...
🌐
Medium
medium.com › @AlexanderObregon › javas-collectors-joining-method-explained-a4adb120b785
Java’s Collectors.joining() Method Explained | Medium
November 2, 2024 - The Collectors.joining() method provides a simple and effective way to combine stream elements into a formatted string. From joining user names to building file paths and query strings, its flexibility makes it a valuable tool for any Java developer.
🌐
Baeldung
baeldung.com › home › java › java streams › string operations with java streams
String Operations with Java and Stream API | Baeldung
January 8, 2024 - public static Map<String, String> arrayToMap(String[] arrayOfString) { return Arrays.asList(arrayOfString) .stream() .map(str -> str.split(":")) .collect(toMap(str -> str[0], str -> str[1])); } Here, “:” is the key-value separator for all ...
🌐
Medium
medium.com › @AlexanderObregon › javas-stream-collect-method-explained-956667984a8f
Java’s Stream.collect() Method Explained | Medium
November 28, 2024 - The combiner method handles merging partial results in parallel stream operations, while the finisher method converts the accumulated StringBuilder into the final String. This setup provides a clear way to aggregate and format stream data for a variety of use cases. The Stream.collect() method is a valuable tool for transforming and aggregating data in Java.
🌐
GeeksforGeeks
geeksforgeeks.org › java › java-8-streams-collectors-joining-method-with-examples
Java 8 Streams | Collectors.joining() method with Examples - GeeksforGeeks
January 22, 2026 - The Collectors.joining() method in Java 8 Streams is a terminal operation used to combine stream elements into a single String.
Find elsewhere
🌐
Javaprogramto
javaprogramto.com › 2020 › 12 › java-8-stream-join-string.html
Java 8 Streams - Join or Append Stream of Strings using Collectors.joining() JavaProgramTo.com
November 26, 2021 - Use Collectors.joining() method joins the values of the stream with a delimiter specified. If the delimiter is not specified then it takes nothing as a separator. So, that final returned string will be having just all values concatenated from ...
🌐
HowToDoInJava
howtodoinjava.com › home › java 8 › join or append stream elements in java
Join or Append Stream Elements in Java
December 13, 2024 - Stream<String> stringStream = Stream.of("Hello", null, "Java", "Streams"); String result = stringStream.filter(element -> element != null) .collect(Collectors.joining(", ")); System.out.println("Joined String: " + result); // Output: Hello, Java, Streams · The String.join() is another simple method for concatenating strings. It works well when converting a collection or array of strings to a single string.
🌐
Java Guides
javaguides.net › 2024 › 09 › how-to-convert-stream-to-string-in-java.html
How to Convert Stream to String in Java 8
September 10, 2024 - Step 1: A stream of strings is created using Stream.of(). Step 2: The Collectors.joining() method is used to concatenate the elements without any delimiter. Step 3: The resulting string is printed. import java.util.stream.Stream; import ...
🌐
Baeldung
baeldung.com › home › java › java string › converting a list to string in java
Converting a List to String in Java | Baeldung
July 30, 2026 - @Test public void whenStringJoinWithNonStringList_thenPrintCustom() { List<Integer> intList = Arrays.asList(1, 2, 3); List<String> strList = intList.stream().map(String::valueOf).collect(Collectors.toList()); System.out.println(String.join(" : ", strList)); }
🌐
IONOS
ionos.com › digital guide › websites › web development › java stream collect
How to use Java collect() to collect and process data - IONOS
November 3, 2023 - Below we il­lus­trate various functions of the Stream.collect() method. You should already be familiar with the basic Java operators before jumping into the col­lec­tion framework. With Java Collect(), we can con­cate­nate a list of strings to get a new string:
🌐
Level Up Lunch
leveluplunch.com › java › examples › convert-java-util-stream-to-string
Convert stream to String - Java
July 10, 2014 - @Test public void stream_to_set() { String streamToString = Stream.of("a", "b", "c") .collect(joining()); assertEquals("abc", streamToString); }
🌐
Medium
rameshfadatare.medium.com › java-stream-collect-method-with-examples-41c9010fa32c
Java Stream collect() Method with Examples | by Ramesh Fadatare | Medium
September 27, 2024 - The collect() method in Java is a part of the java.util.stream.Stream interface. In this guide, we will learn how to use collect() method in Java with practical examples and real-world use cases to better understand its functionality.
🌐
Java67
java67.com › 2018 › 06 › java-8-streamcollect-example.html
4 Examples of Stream.collect() method in Java 8 | Java67
Since Set doesn't provide ordering and doesn't allow duplicate, any duplicate from Stream will be discarded and the order of elements will be lost. Here is an example to convert Stream to Set using collect() and Collectors in Java 8: The set of String in this example contains all the String which starts with the letter C like C and C++. The order will be lost and any duplicate will be removed.
🌐
Oracle
docs.oracle.com › javase › 8 › docs › api › java › util › StringJoiner.html
StringJoiner (Java Platform SE 8 )
July 21, 2026 - A StringJoiner may be employed to create formatted output from a Stream using Collectors.joining(CharSequence).