Package org.dom4j.io

Examples of org.dom4j.io.OutputFormat


            vCard.addElement("ORG").addElement("ORGUNIT").setText(businessDepartment.trim());
        }
        // Generate content to store in property
        String vcardXML;
        StringWriter writer = new StringWriter();
        OutputFormat prettyPrinter = OutputFormat.createPrettyPrint();
        XMLWriter xmlWriter = new XMLWriter(writer, prettyPrinter);
        try {
            xmlWriter.write(vCard);
            vcardXML = writer.toString();
        }
View Full Code Here


            buffer.setAutoExpand(true);

            boolean errorDelivering = false;
            try {
                XMLWriter xmlSerializer =
                        new XMLWriter(new ByteBufferWriter(buffer, encoder.get()), new OutputFormat());
                xmlSerializer.write(packet.getElement());
                xmlSerializer.flush();
                if (flashClient) {
                    buffer.put((byte) '\0');
                }
View Full Code Here

      if ("getOverallStats".equals(method)) {
        getOverallStats(root);
      } else {
        throw new IllegalArgumentException("Unknown method: " + method);
      }
      OutputFormat format = OutputFormat.createPrettyPrint();
      //format.setTrimText(false); // must do this because dom4j 1.x has an error that removes whitespace from text between two tags
      ByteArrayOutputStream baos = new ByteArrayOutputStream();
      XMLWriter output = new XMLWriter(new OutputStreamWriter(baos), format);
      output.write(document);
      output.close();
      response.setContentType("text/xml");
      response.setStatus(HttpServletResponse.SC_OK);
      response.setContentLength(baos.size());
      response.setCharacterEncoding(format.getEncoding());
      response.getOutputStream().write(baos.toByteArray());
    } catch (Exception e) {
      logger.error("An exception occurred when handling an accounting information request", e);
      response.setStatus(HttpServletResponse.SC_BAD_REQUEST);
    }
View Full Code Here

             * XMLWriter把packet中的xml文件转换成一个流,写进IoBuffer在通过session向client端发送
             *
             */
        XMLWriter xmlSerializer = new XMLWriter(new IoBufferWriter(
            buffer, (CharsetEncoder) encoder.get()),
            new OutputFormat());
        xmlSerializer.write(packet.getElement());
              xmlSerializer.flush();
              // IoBuffer流写完
              buffer.flip();
              // 通过session向外写
View Full Code Here

   * @see com.itextpdf.rups.io.OutputStreamResource#writeTo(java.io.OutputStream)
   */
  public void writeTo(OutputStream os) throws IOException {
    if (xfaDocument == null)
      return;
    OutputFormat format = new OutputFormat("   ", true);
        XMLWriter writer = new XMLWriter(os, format);
        writer.write(xfaDocument);
  }
View Full Code Here

    public static void saveProjects()
    {
        try
        {
            // Saving the projects to the temp projects file
            OutputFormat outformat = OutputFormat.createPrettyPrint();
            outformat.setEncoding( "UTF-8" );
            XMLWriter writer = new XMLWriter( new FileOutputStream( getTempProjectsFile() ), outformat );
            writer.write( ProjectsExporter.toDocument( Activator.getDefault().getProjectsHandler().getProjects()
                .toArray( new Project[0] ) ) );
            writer.flush();

            // Copying the temp projects file to the final location
            String content = FileUtils.readFileToString( getTempProjectsFile(), "UTF-8" );
            FileUtils.writeStringToFile( getProjectsFile(), content, "UTF-8" );
        }
        catch ( IOException e )
        {
            // If an error occurs when saving to the temp projects file or
            // when copying the temp projects file to the final location,
            // we try to save the projects directly to the final location.
            try
            {
                OutputFormat outformat = OutputFormat.createPrettyPrint();
                outformat.setEncoding( "UTF-8" );
                XMLWriter writer = new XMLWriter( new FileOutputStream( getProjectsFile() ), outformat );
                writer.write( ProjectsExporter.toDocument( Activator.getDefault().getProjectsHandler().getProjects()
                    .toArray( new Project[0] ) ) );
                writer.flush();
            }
View Full Code Here

                writeBrowserConnection( root, browserConnection );
            }
        }

        // Writing the file to disk
        OutputFormat outformat = OutputFormat.createPrettyPrint();
        outformat.setEncoding( "UTF-8" );
        XMLWriter writer = new XMLWriter( stream, outformat );
        writer.write( document );
        writer.flush();
    }
View Full Code Here

                addConnection( root, connection );
            }
        }

        // Writing the file to disk
        OutputFormat outformat = OutputFormat.createPrettyPrint();
        outformat.setEncoding( "UTF-8" );
        XMLWriter writer = new XMLWriter( stream, outformat );
        writer.write( document );
        writer.flush();
    }
View Full Code Here

                addFolderConnection( root, connectionFolder );
            }
        }

        // Writing the file to disk
        OutputFormat outformat = OutputFormat.createPrettyPrint();
        outformat.setEncoding( "UTF-8" );
        XMLWriter writer = new XMLWriter( stream, outformat );
        writer.write( document );
        writer.flush();
    }
View Full Code Here

                    {
                        monitor.subTask( project.getName() );

                        try
                        {
                            OutputFormat outformat = OutputFormat.createPrettyPrint();
                            outformat.setEncoding( "UTF-8" );
                            XMLWriter writer = new XMLWriter( new FileOutputStream( exportDirectory + "/"
                                + project.getName() + ".schemaproject" ), outformat );
                            writer.write( ProjectsExporter.toDocument( project ) );
                            writer.flush();
                        }
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.