fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.util.stream.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. public static void main (String[] args) throws java.lang.Exception
  11. {
  12. String input = "str1=wordA&str2=wordB&desc3=&int=0";
  13. Map<String, String> pairs = Arrays.stream(input.split("&"))
  14. .map(s -> s.split("=", -1))
  15. .collect(Collectors.toMap(a -> a[0], a -> a[1]));
  16. System.out.println(pairs);
  17.  
  18. }
  19. }
Success #stdin #stdout 0.09s 711680KB
stdin
Standard input is empty
stdout
{desc3=, str1=wordA, str2=wordB, int=0}