Browse Source

REPORT-16986 模板制作埋点的tpl.info里,用户如果是中文名会乱码

bugfix/10.0
plough 6 years ago
parent
commit
6f1747409b
  1. 17
      designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java

17
designer-base/src/main/java/com/fr/design/mainframe/template/info/TemplateInfoCollector.java

@ -12,12 +12,14 @@ import com.fr.stable.xml.XMLTools;
import com.fr.stable.xml.XMLWriter; import com.fr.stable.xml.XMLWriter;
import com.fr.stable.xml.XMLableReader; import com.fr.stable.xml.XMLableReader;
import com.fr.third.javax.xml.stream.XMLStreamException; import com.fr.third.javax.xml.stream.XMLStreamException;
import com.fr.workspace.WorkContext; import com.fr.third.org.apache.commons.io.FileUtils;
import java.io.ByteArrayOutputStream;
import java.io.File; import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException; import java.io.FileNotFoundException;
import java.io.FileOutputStream; import java.io.InputStreamReader;
import java.io.FileReader; import java.nio.charset.StandardCharsets;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
@ -133,7 +135,8 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter {
return; return;
} }
try { try {
XMLableReader xmlReader = XMLableReader.createXMLableReader(new FileReader(getInfoFile())); InputStreamReader isReader = new InputStreamReader(new FileInputStream(getInfoFile()), StandardCharsets.UTF_8);
XMLableReader xmlReader = XMLableReader.createXMLableReader(isReader);
xmlReader.readXMLObject(this); xmlReader.readXMLObject(this);
} catch (XMLStreamException e) { } catch (XMLStreamException e) {
FineLoggerFactory.getLogger().error(e.getMessage(), e); FineLoggerFactory.getLogger().error(e.getMessage(), e);
@ -160,8 +163,12 @@ public class TemplateInfoCollector implements XMLReadable, XMLWriter {
*/ */
private void saveInfo() { private void saveInfo() {
try { try {
FileOutputStream out = new FileOutputStream(getInfoFile()); ByteArrayOutputStream out = new ByteArrayOutputStream();
XMLTools.writeOutputStreamXML(this, out); XMLTools.writeOutputStreamXML(this, out);
out.flush();
out.close();
String fileContent = new String(out.toByteArray(), StandardCharsets.UTF_8);
FileUtils.writeStringToFile(getInfoFile(), fileContent, StandardCharsets.UTF_8);
} catch (Exception ex) { } catch (Exception ex) {
FineLoggerFactory.getLogger().error(ex.getMessage()); FineLoggerFactory.getLogger().error(ex.getMessage());
} }

Loading…
Cancel
Save