question: private static void saveDiagram ( String source , Bean < ? extends Configuration > configuration , OutputStream stream , String encoding ) throws IOException , XMLException { if ( configuration != null ) { Document document = DocUtil . newDocument ( ) ; Element root = document . createElement ( "diagram" ) ; document . appendChild ( root ) ; BeanConverter converter = new BeanConverter ( configuration , document ) ; Element sourceElem = document . createElement ( "source" ) ; CDATASection sourceNode = document . createCDATASection ( source ) ; sourceElem . appendChild ( sourceNode ) ; root . appendChild ( sourceElem ) ; Element configurationNode = converter . createElement ( "configuration" ) ; root . appendChild ( configurationNode ) ; DocUtil . writeDocument ( document , encoding , stream ) ; } else { OutputStreamWriter osw = new OutputStreamWriter ( stream , encoding ) ; PrintWriter pw = new PrintWriter ( osw ) ; pw . print ( source ) ; pw . flush ( ) ; } }
target:  Saves a diagram specification (and a configuration), using a stream.