Want more features on Pastebin? Sign Up, it's FREE!
Guest

Untitled

By: a guest on Dec 1st, 2012  |  syntax: None  |  size: 1.42 KB  |  views: 209  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. status:ok [XXX][a=XXX b=XXX c=XXX d=XXX e=0 f=XXX g=XXX h=XXX i=XXX j=XXX
  2. k=XXX l=XXX m=XXX n=[[XXX][XXX]] p=[[XXX][XXX][XXX][XXX][XXX][XXX][XXX]]]
  3. end:end
  4.        
  5. status:ok [XXX][a=XXX b=XXX  c=XXX d=XXX d2=XXX e=XXX  f=XXX g=XXX h=XXX i=XXX j=XXX
  6. k=XXX l=XXX m=XXX n=[[XXX][XXX]] p=[[XXX][XXX][XXX][XXX][XXX][XXX][XXX]]]
  7. end:end
  8.        
  9. HashMap<String,Object> myHashMap = new HashMap();
  10. myHashMap.put(a, XXX);
  11. ....
  12. myHashMap.put(p,array-of-all-[XXX]);
  13.        
  14. String s ="status:ok [XXX][a=XXX b=XXX c=XXX d=XXX e=0 f=XXX g=XXX h=XXX i=XXX j=XXX k=XXX l=XXX m=XXX n=[[XXX][XXX]] p=[[XXX][XXX][XXX][XXX][XXX][XXX][XXX]]] end:end".replaceAll("end:end", "");
  15.  
  16.     String [] ss  = s.split("=");
  17.     HashMap<Character,Object> myHashMap = new HashMap();
  18.     try{
  19.     for(int i=0;i<ss.length;i++){
  20.  
  21.         myHashMap.put(ss[i].charAt(ss[i].length()-1), ss[i+1].substring(0, ss[i+1].length()-1).trim());
  22.  
  23.     }
  24.  
  25.     }catch(Exception e){
  26.         // do nothing
  27.     }
  28.       System.out.println(myHashMap);
  29.     }
  30.        
  31. String str = "status:ok [XXX][a=XXX b=XXX c=XXX d=XXX e=0 f=XXX g=XXX h=XXX i=XXX j=XXX k=XXX l=XXX m=XXX n=[[XXX][XXX]] p=[[XXX][XXX][XXX][XXX][XXX][XXX][XXX]]] end:end";
  32. String[] splitStrA = str.split(" ");        
  33. HashMap<String,String> map = new HashMap() ;
  34. for (String splitStr : splitStrA) {
  35.     String[] splitStr1 = splitStr.split("=");
  36.     if (splitStr1.length == 2) {
  37.         map.put(splitStr1[0], splitStr1[1]);
  38.     }
  39. }
  40. System.out.println(map);
clone this paste RAW Paste Data