fork(6) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.regex.*;
  7. import java.util.HashMap;
  8. /* Name of the class has to be "Main" only if the class is public. */
  9. class Ideone
  10. {
  11. public static void main (String[] args) throws java.lang.Exception
  12. {
  13. String str = "SiteId:BLR232#Latitude:12.918444#Longitude:77.5940136#NetworkType:4g#Type:NONE#Type of Complaint:Call Drop#Sample Number:7022979575#Problem Description:agshjs vshsijsb#";
  14. String[] kvps = str.split("#");
  15. Map<String, String> res = new HashMap<String, String>();
  16. for(String kvp : kvps) {
  17. String[] parts = kvp.split(":");
  18. res.put(parts[0], parts[1]);
  19. System.out.println(parts[0] + " - " + parts[1]);
  20. }
  21.  
  22.  
  23. }
  24. }
Success #stdin #stdout 0.13s 320576KB
stdin
Standard input is empty
stdout
SiteId - BLR232
Latitude - 12.918444
Longitude - 77.5940136
NetworkType - 4g
Type - NONE
Type of Complaint - Call Drop
Sample Number - 7022979575
Problem Description - agshjs vshsijsb