| Dom4jUtil | Line # 12 | 8 | 2 | 0% |
0.0
|
| No Tests | |||
| 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 | 0 |
public static void saveDocumentTo(org.dom4j.Document doc, String folder, String fileName) |
| 17 | throws IOException | |
| 18 | { | |
| 19 | 0 | OutputFormat format = OutputFormat.createPrettyPrint(); |
| 20 | 0 | File file = new File(folder, fileName); |
| 21 | ||
| 22 | 0 | if (!file.exists()) |
| 23 | { | |
| 24 | 0 | file.createNewFile(); |
| 25 | } | |
| 26 | ||
| 27 | 0 | OutputStreamWriter writeOut = new OutputStreamWriter(new FileOutputStream(file), "UTF-8"); |
| 28 | 0 | XMLWriter writer = new XMLWriter(writeOut, format); |
| 29 | 0 | writer.write(doc); |
| 30 | 0 | writer.close(); |
| 31 | } | |
| 32 | } | |
|
||||||||||