|
|
|
@ -1,6 +1,7 @@
|
|
|
|
|
package com.fr.design.mainframe.template.info; |
|
|
|
|
|
|
|
|
|
import com.fr.base.FRContext; |
|
|
|
|
import com.fr.base.io.XMLReadHelper; |
|
|
|
|
import com.fr.design.DesignerEnvManager; |
|
|
|
|
import com.fr.log.FineLoggerFactory; |
|
|
|
|
import com.fr.stable.ProductConstants; |
|
|
|
@ -18,7 +19,8 @@ import java.io.ByteArrayOutputStream;
|
|
|
|
|
import java.io.File; |
|
|
|
|
import java.io.FileInputStream; |
|
|
|
|
import java.io.FileNotFoundException; |
|
|
|
|
import java.io.InputStreamReader; |
|
|
|
|
import java.io.IOException; |
|
|
|
|
import java.io.InputStream; |
|
|
|
|
import java.nio.charset.StandardCharsets; |
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
import java.util.HashMap; |
|
|
|
@ -134,14 +136,24 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter {
|
|
|
|
|
if (!getInfoFile().exists()) { |
|
|
|
|
return; |
|
|
|
|
} |
|
|
|
|
try { |
|
|
|
|
InputStreamReader isReader = new InputStreamReader(new FileInputStream(getInfoFile()), StandardCharsets.UTF_8); |
|
|
|
|
XMLableReader xmlReader = XMLableReader.createXMLableReader(isReader); |
|
|
|
|
xmlReader.readXMLObject(this); |
|
|
|
|
} catch (XMLStreamException e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
|
|
|
|
|
XMLableReader reader = null; |
|
|
|
|
try (InputStream in = new FileInputStream(getInfoFile())) { |
|
|
|
|
// XMLableReader 还是应该考虑实现 Closable 接口的,这样就能使用 try-with 语句了
|
|
|
|
|
reader = XMLReadHelper.createXMLableReader(in, XMLPrintWriter.XML_ENCODER); |
|
|
|
|
reader.readXMLObject(this); |
|
|
|
|
} catch (FileNotFoundException e) { |
|
|
|
|
// do nothing
|
|
|
|
|
} catch (XMLStreamException | IOException e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
} finally { |
|
|
|
|
try { |
|
|
|
|
if (reader != null) { |
|
|
|
|
reader.close(); |
|
|
|
|
} |
|
|
|
|
} catch (XMLStreamException e) { |
|
|
|
|
FineLoggerFactory.getLogger().error(e.getMessage(), e); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|