Package org.dom4j.io

Examples of org.dom4j.io.OutputFormat


        this.writer = writer;
    }

    public void doWork() {
        try {
            XMLWriter output = new XMLWriter(writer, new OutputFormat("  ", true));
            output.write(createDocument());
            output.close();
        } catch (Exception ex) {
            throw new RuntimeException(ex);
        }
View Full Code Here


            settingsElement.addElement(entry.getKey()).
                    addAttribute("class", clazz.getName()).
                    setText(w.toString(entry.getValue()));
        }

        XMLWriter output = new XMLWriter(new FileOutputStream(xmlFile), new OutputFormat("  ", true));
        output.write(document);
        output.close();
    }
View Full Code Here

    return (root != null) ? root.getStringValue() : "";
  }

  public String asXML() {
    OutputFormat format = new OutputFormat();
    format.setEncoding(encoding);

    try {
      StringWriter out = new StringWriter();
      XMLWriter writer = new XMLWriter(out, format);
      writer.write(this);
View Full Code Here

    }
  }

  @Override
  public void write(Writer out) throws IOException {
    OutputFormat format = new OutputFormat();
    format.setEncoding(encoding);

    XMLWriter writer = new XMLWriter(out, format);
    writer.write(this);
  }
View Full Code Here

  }

  public String asXML() {
    try {
      StringWriter out = new StringWriter();
      XMLWriter writer = new XMLWriter(out, new OutputFormat());

      writer.write(this);
      writer.flush();

      return out.toString();
View Full Code Here

    }
  }

  @Override
  public void write(Writer out) throws IOException {
    XMLWriter writer = new XMLWriter(out, new OutputFormat());
    writer.write(this);
  }
View Full Code Here

   *            编码方式.
   * @return 格式化以后的XML字符串.如果输入为null或空字符串,则不做任何处理.
   */
  public static String getPrettyString(Document doc, String encoding) {
    StringWriter writer = new StringWriter();
    OutputFormat format = OutputFormat.createPrettyPrint();
    if (encoding == null || "".equals(encoding.trim())) {
      encoding = "GBK";
    }
    format.setEncoding(encoding);
    XMLWriter xmlwriter = new XMLWriter(writer, format);

    try {
      xmlwriter.write(doc);
    } catch (IOException e) {
View Full Code Here

                if (pwd != null && pwd.length() > 0) {
                    node.addAttribute("password", pwd);
                }
            }
            BufferedOutputStream bos = new BufferedOutputStream(new FileOutputStream(selectedFile));
            OutputFormat format = OutputFormat.createPrettyPrint();
            format.setEncoding("UTF-8");
            XMLWriter xmlWriter = new XMLWriter(bos, format);
            xmlWriter.write(document);
            xmlWriter.flush();
            xmlWriter.close();
            LOG.info(GettextResource.gettext(Configuration.getInstance().getI18nResourceBundle(), "File xml saved."));
View Full Code Here

            info.writeXML(root);
         }

         File versionsXml = new File(jbossHome, "jar-versions.xml");
         FileWriter versionInfo = new FileWriter(versionsXml);
         OutputFormat outformat = OutputFormat.createPrettyPrint();
         XMLWriter writer = new XMLWriter(versionInfo, outformat);
         writer.setEscapeText(true);
         writer.write(doc);
         writer.flush();
         versionInfo.close();
View Full Code Here

   * @param contextPath JAXB context path to be used
   * @see javax.xml.bind.JAXBContext
   */
  public JAXBWriter(String contextPath) {
    super(contextPath);
    outputFormat = new OutputFormat();
  }
View Full Code Here

TOP

Related Classes of org.dom4j.io.OutputFormat

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.