title: How to persist EMF objects to OutputStream?
body: <p>This how I persist two EMF objects (a static <code>shelf</code> and a dynamic <code>md5</code>) into a zipped binary file:</p>
  <pre><code>static void save(Shelf shelf, String file, EClass md5class) throws Exception { 
    EObject md5 = stringToMD5EObject(&quot;0x0abc&quot;, md5class); 
    Resource resource = createResource(file, md5class.getEPackage(), shelf.eClass().getEPackage());
    resource.getContents().add(md5); 
    resource.getContents().add(shelf); 
    resource.save(options());
  }
  static Resource createResource(String file, EPackage... packages) {
    ResourceSet resourceSet = new ResourceSetImpl();
    Resource.Factory factory = uri -&gt; new BinaryResourceImpl(uri);
    resourceSet.getResourceFactoryRegistry().getExtensionToFactoryMap().put(&quot;bin&quot;, factory); 
    for (EPackage p : packages) resourceSet.getPackageRegistry().put(p.getNsURI(), p);
    URI fileURI = URI.createFileURI(new File(file).getAbsolutePath());
    return resourceSet.createResource(fileURI);
  }
  static Map&lt;String, Object&gt; options() {
    return Collections.singletonMap(BinaryResourceImpl.OPTION_ZIP, Boolean.TRUE);
  }
  </code></pre>
  <p>The question is how to configure the resource if I'm given an <em>already open</em> OutputStream, that is without no access whatsoever to the filename?</p>