View Javadoc

1   /*
2    * Copyright (c) 2003 by Atlassian Software Systems Pty. Ltd.
3    * All rights reserved.
4    */
5   package com.atlassian.core.util;
6   
7   import org.dom4j.io.OutputFormat;
8   import org.dom4j.io.XMLWriter;
9   
10  import java.io.*;
11  
12  public class Dom4jUtil
13  {
14      //~ Methods --------------------------------------------------------------------------------------------------------
15  
16      public static void saveDocumentTo(org.dom4j.Document doc, String folder, String fileName)
17          throws IOException
18      {
19          OutputFormat format = OutputFormat.createPrettyPrint();
20          File file = new File(folder, fileName);
21  
22          if (!file.exists())
23          {
24              file.createNewFile();
25          }
26  
27          OutputStreamWriter writeOut = new OutputStreamWriter(new FileOutputStream(file), "UTF-8");
28          XMLWriter writer = new XMLWriter(writeOut, format);
29          writer.write(doc);
30          writer.close();
31      }
32  }