title: Java, How to Instance HttpCookie from a String, any convenient ways?
body: <p>I have got a cookie string from HTTP response header like the following line:</p>
  
  <pre><code>name=value; path=/; domain=.g.cn; expire=...
  </code></pre>
  
  <p>I can parse the above line to key-value pairs, and, also it's easy to set the name and value to HttpCookie instance as this pair comes the first. </p>
  
  <p>But how to set the other pairs since I don't know which set-method corresponds to the name of the next name-value pair. Traverse all possible keys a cookie may contian and call the matched set-method, like below snippet?</p>
  
  <pre><code>if (key.equalsIgnoreCase("path"))
   cookie.setPath(value);
  else if (key.equalsIgnoreCase("domain"))
   cookie.setDomain(value);
  </code></pre>
  
  <p>That's foolish, any convenient ways?
  Thanks in advance.</p>