Package org.dom4j.io

Examples of org.dom4j.io.OutputFormat


    protected void setUp() throws Exception {
        super.setUp();

        Dom4JDriver driver = new Dom4JDriver();

        OutputFormat format = OutputFormat.createCompactFormat();
        format.setTrimText(false);
        format.setSuppressDeclaration(true);
        driver.setOutputFormat(format);

        out = new StringWriter();
        writer = driver.createWriter(out);
    }
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

                addServer( server, root );
            }
        }

        // Writing the file to the stream
        OutputFormat outformat = OutputFormat.createPrettyPrint();
        outformat.setEncoding( "UTF-8" );
        XMLWriter writer = new XMLWriter( outputStream, outformat );
        writer.write( document );
        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

           
            connection = _dataSource.getConnection();
           
            dumpMetaData(root, connection.getMetaData());

            OutputFormat outputFormat = OutputFormat.createPrettyPrint();
            XMLWriter    xmlWriter    = null;

            outputFormat.setEncoding(_outputEncoding);
            if (_outputFile == null)
            {
                xmlWriter = new XMLWriter(System.out, outputFormat);
            }
            else
View Full Code Here

                FileUser user = (FileUser) users.get(userKey);
                Element userElement = root.addElement("user").addAttribute("id", user.name).addAttribute("password", user.password);
            }

            // print it nicely
            OutputFormat format = OutputFormat.createPrettyPrint();
            XMLWriter writer = new XMLWriter(new FileWriter(storeFile));
            writer.write(document);
            writer.close();

            return true;
View Full Code Here

                    groupElement.addElement("user").addAttribute("id", j.next().toString());
                }
            }

            // print it nicely
            OutputFormat format = OutputFormat.createPrettyPrint();
            XMLWriter writer = new XMLWriter(new FileWriter(storeFile));
            writer.write(document);
            writer.close();

            return true;
View Full Code Here

                throw new ConversionException(data.getClass());
            }

            Node node = (Node) data;

            OutputFormat outformat = OutputFormat.createCompactFormat();
            outformat.setEncoding("UTF-8");

            // Setup the destination
            StringWriter xml = new StringWriter();

            XMLWriter writer = new XMLWriter(xml, outformat);
View Full Code Here

   *         else <b>false</b>.
   */
  public static boolean saveXmlInStream(Document xmlContent,
      OutputStream outStream) {
    try {
      OutputFormat outformat = OutputFormat.createPrettyPrint();
      outformat.setEncoding("UTF-8");
      XMLWriter writer = new XMLWriter(outStream, outformat);
      writer.write(xmlContent);
    } catch (Exception e) {
      return false;
    }
View Full Code Here

    public String updateConfigDocument(Document newConfig) throws UnsupportedEncodingException, FileNotFoundException, IOException, ParserConfigurationException, DocumentException {
        String newTimestamp = WGACore.DATEFORMAT_GMT.format(new Date());
        newConfig.getRootElement().addAttribute("timestamp", newTimestamp);

        OutputFormat outputFormat = OutputFormat.createPrettyPrint();
        outputFormat.setTrimText(true);
        outputFormat.setNewlines(true);

        XMLWriter writer = new XMLWriter(new FileOutputStream(getConfigFile()), outputFormat);
        writer.write(newConfig);
        writer.close();
        return newTimestamp;
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.