@Override public void doSave(OutputStream outputStream, Map<?, ?> options) throws IOException { if (getContents().isEmpty()) throw new IllegalStateException("The Xtext resource must contain at least one element."); SaveOptions saveOptions = SaveOptions.getOptions(options); setEncodingFromOptions(options); serializer.serialize(getContents().get(0), new OutputStreamWriter(outputStream, getEncoding()), saveOptions); }