DocumentBuilderFactory dbf = DocumentBuilderFactory.newInstance();
//Using factory get an instance of document builder
DocumentBuilder db = dbf.newDocumentBuilder();
ZipReader zip;
Document dom;
// Open the file
if (filename.endsWith(".template")){
// Older version
zip = new ZipReader(null, 1);
FileInputStream fis = new FileInputStream(filename);
GZIPInputStream zis = null;
try{
zis = new GZIPInputStream(fis);
}catch(IOException e){
zis = null;
}
//parse using builder to get DOM representation of the XML file
if (zis != null){
// file in GZIP format
dom = db.parse(zis);
}else{
// uncompressed file
dom = db.parse(filename);
}
}else{
// Newer format, zip
zip = new ZipReader(filename, DatasoulMainForm.FILE_FORMAT_VERSION);
dom = db.parse(zip.getMainInputStream());
}
Node node = dom.getElementsByTagName("DisplayTemplate").item(0);
this.readObject(node, zip);
// Close the input stream
zip.close();
// upgrade from older versions
// version up to 1.2 had fixed resolution at 640x480
if (getDatasoulFileVersion() < 1){