cdm/src/main/java/ucar/util/prefs/XMLStore.java
public void save(OutputStream out) throws java.io.IOException {
    outputExceptionMessage = null;

    // the OutputMunger strips off the XMLEncoder header
    OutputMunger bos = new OutputMunger( out);
    PrintWriter pw = new PrintWriter( new OutputStreamWriter(bos,
            CDM.utf8Charset));

    XMLEncoder beanEncoder = new XMLEncoder( bos);
    beanEncoder.setExceptionListener(new ExceptionListener() {
      public void exceptionThrown(Exception exception) {
        System.out.println("XMLStore.save() got Exception: abort saving the preferences!");
        exception.printStackTrace();
        outputExceptionMessage = exception.getMessage();
      }
    });

    pw.printf("<?xml version='1.0' encoding='UTF-8'?>%n");
    pw.printf("<preferences EXTERNAL_XML_VERSION='1.0'>%n");
    if (!rootPrefs.isUserNode())
      pw.printf("  <root type='system'>%n");
    else
      pw.printf("  <root type='user'>%n");

    Indent indent = new Indent(2);
    indent.incr();
    writeXmlNode(bos, pw, rootPrefs, beanEncoder, indent);
    if (outputExceptionMessage != null)
      throw new IOException(outputExceptionMessage);    

    pw.printf("  </root>%n");
    pw.printf("</preferences>%n");
    pw.flush();
  }
public void save(OutputStream out) throws java.io.IOException {
    outputExceptionMessage = null;

    // the OutputMunger strips off the XMLEncoder header
    OutputMunger bos = new OutputMunger( out);
    PrintWriter pw = new PrintWriter( new OutputStreamWriter(bos,
            CDM.utf8Charset));

    XMLEncoder beanEncoder = new XMLEncoder( bos);
    beanEncoder.setExceptionListener(new ExceptionListener() {
      public void exceptionThrown(Exception exception) {
        System.out.println("XMLStore.save() got Exception: abort saving the preferences!");
        exception.printStackTrace();
        outputExceptionMessage = exception.getMessage();
      }
    });

    pw.printf("<?xml version='1.0' encoding='UTF-8'?>%n");
    pw.printf("<preferences EXTERNAL_XML_VERSION='1.0'>%n");
    if (!rootPrefs.isUserNode())
      pw.printf("  <root type='system'>%n");
    else
      pw.printf("  <root type='user'>%n");

    Indent indent = new Indent(2);
    indent.incr();
    writeXmlNode(bos, pw, rootPrefs, beanEncoder, indent);
    if (outputExceptionMessage != null)
      throw new IOException(outputExceptionMessage);    

    pw.printf("  </root>%n");
    pw.printf("</preferences>%n");
    pw.flush();
  }
public void save ( OutputStream out ) throws java . io . IOException { outputExceptionMessage = null ; // the OutputMunger strips off the XMLEncoder header OutputMunger bos = new OutputMunger ( out ) ; PrintWriter pw = new PrintWriter ( new OutputStreamWriter ( bos , CDM . utf8Charset ) ) ; XMLEncoder beanEncoder = new XMLEncoder ( bos ) ; beanEncoder . setExceptionListener ( new ExceptionListener ( ) { public void exceptionThrown ( Exception exception ) { System . out . println ( "XMLStore.save() got Exception: abort saving the preferences!" ) ; exception . printStackTrace ( ) ; outputExceptionMessage = exception . getMessage ( ) ; } } ) ; pw . printf ( "<?xml version='1.0' encoding='UTF-8'?>%n" ) ; pw . printf ( "<preferences EXTERNAL_XML_VERSION='1.0'>%n" ) ; if ( ! rootPrefs . isUserNode ( ) ) pw . printf ( "  <root type='system'>%n" ) ; else pw . printf ( "  <root type='user'>%n" ) ; Indent indent = new Indent ( 2 ) ; indent . incr ( ) ; writeXmlNode ( bos , pw , rootPrefs , beanEncoder , indent ) ; if ( outputExceptionMessage != null ) throw new IOException ( outputExceptionMessage ) ; pw . printf ( "  </root>%n" ) ; pw . printf ( "</preferences>%n" ) ; pw . flush ( ) ; }
Save the current state of the Preferences tree to the given OutputStream.
Save the current state of the Preferences tree to the given OutputStream .