Exemplo n.º 1
0
 /**
  * Write our internal representation to output stream <code>os</code>, in the appropriate way as
  * determined by our <code>type</code>.
  *
  * @param os os
  * @throws TransformerConfigurationException TransformerConfigurationException
  * @throws FileNotFoundException FileNotFoundException
  * @throws TransformerException TransformerException
  * @throws IOException IOException
  * @throws Exception Exception
  */
 public void writeTo(OutputStream os)
     throws TransformerConfigurationException, FileNotFoundException, TransformerException,
         IOException, Exception {
   if (type.isXMLType()) {
     if (writer == null) writer = new MaryNormalisedWriter();
     if (logger.getEffectiveLevel().equals(Level.DEBUG)) {
       ByteArrayOutputStream debugOut = new ByteArrayOutputStream();
       writer.output(xmlDocument, debugOut);
       logger.debug(debugOut.toString());
     }
     writer.output(xmlDocument, new BufferedOutputStream(os));
   } else if (type.isTextType()) { // caution: XML types are text types!
     writeTo(new OutputStreamWriter(os, "UTF-8"));
   } else { // audio
     logger.debug("Writing audio output, frame length " + audio.getFrameLength());
     AudioSystem.write(audio, audioFileFormat.getType(), os);
     os.flush();
     os.close();
   }
 }