Improve export methods.
This commit is contained in:
parent
9e914df643
commit
d409b8a8f3
1 changed files with 34 additions and 7 deletions
|
@ -15,6 +15,7 @@ import fr.devinsy.util.xml.XMLReader;
|
|||
import fr.devinsy.util.xml.XMLTag;
|
||||
import fr.devinsy.util.xml.XMLTag.TagType;
|
||||
import fr.devinsy.util.xml.XMLWriter;
|
||||
import fr.devinsy.util.xml.XMLZipWriter;
|
||||
|
||||
/**
|
||||
* This class represents a AccountManager File reader and writer.
|
||||
|
@ -24,6 +25,23 @@ import fr.devinsy.util.xml.XMLWriter;
|
|||
public class XMLSikevaDB {
|
||||
static private final Logger logger = LoggerFactory.getLogger(XMLSikevaDB.class);
|
||||
|
||||
/**
|
||||
* Saves a net in a file.
|
||||
*
|
||||
* @param file
|
||||
* Target.
|
||||
* @param source
|
||||
* Source.
|
||||
*
|
||||
*/
|
||||
public static void export(final OutputStream out, final SikevaDB source) throws Exception {
|
||||
//
|
||||
String fileName = "sikevadb-" + DateTime.now().toString("yyyy-MM-dd-HH'h'mm'mn'ss's'") + ".xml.zip";
|
||||
|
||||
//
|
||||
export(out, source, fileName);
|
||||
}
|
||||
|
||||
/**
|
||||
* Saves a net in a file.
|
||||
*
|
||||
|
@ -39,17 +57,26 @@ public class XMLSikevaDB {
|
|||
throw new NullPointerException("out is null.");
|
||||
} else if (source == null) {
|
||||
throw new NullPointerException("source is null.");
|
||||
} else if (fileName == null) {
|
||||
export(out, source, fileName);
|
||||
} else {
|
||||
//
|
||||
XMLWriter target = new XMLWriter(out);// new XMLZipWriter(out,
|
||||
// fileName,
|
||||
// "Generated by SikevaDB.");
|
||||
XMLZipWriter target = null;
|
||||
try {
|
||||
//
|
||||
target = new XMLZipWriter(out, fileName, "Generated by SikevaDB.");
|
||||
|
||||
//
|
||||
target.writeXMLHeader();
|
||||
//
|
||||
target.writeXMLHeader();
|
||||
|
||||
//
|
||||
write(target, source);
|
||||
//
|
||||
write(target, source);
|
||||
|
||||
} finally {
|
||||
if (target != null) {
|
||||
target.close();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue