title: Mimetypes for ImageIO read() and write()
body: <p>I am trying to use Mime Types to define the output for ImageIO. The simple write() method</p>
  
  <pre><code>public static boolean write(RenderedImage im,
              String formatName,
              OutputStream output)
                       throws IOException
  </code></pre>
  
  <p>uses " informal name of the format." (e.g. "png"). Is there a simple equivalent for mimetypes (e.g.  "image/png") or failing that code that achieves the purpose of writing an image? The only starting point I have found is</p>
  
  <pre><code>public static Iterator&lt;ImageWriter&gt; getImageWritersByMIMEType(String MIMEType)
  </code></pre>
  
  <p>which seems much more complex, requiring <code>ImageWriter</code>, <code>IIOStream</code> etc. and I haven't managed to create a solution.</p>
  
  <p>UPDATE: The reason I am using MIME is that it is a formal part of the image in SVG, e.g. </p>
  
  <pre><code> xlink:href="data:image/png;base64,iVBORw0KGgoAAAA...
  </code></pre>
  
  <p>and it seemed appropriate to use it rather than converting it to less defined "informal" formats. I managed to find a precise solution (in java2s.com) to my question and have added it as an answer.</p>