title: how to write IvParameterSpec to a file?
body: <p>I wrote my SecretKey to a file using the following code. Similarly, I have to write my ivParameterSpec to another file. How can I do this?</p>
  
  <pre><code>SecretKey key = KeyGenerator.getInstance("AES").generateKey();
  ObjectOutputStream secretkeyOS = new ObjectOutputStream(new FileOutputStream("publicKeyFile"));
  secretkeyOS.writeObject(key);
  secretkeyOS.close();
  
  AlgorithmParameterSpec paramSpec1 = new IvParameterSpec(iv);
  session.setAttribute("secParam", paramSpec1);
  ObjectOutputStream paramOS = new ObjectOutputStream(new FileOutputStream("paramFile"));
  paramOS.writeObject(paramSpec1);
  paramOS.close();
  </code></pre>