]> source.dussan.org Git - poi.git/commitdiff
use commons-io StringBuilderWriter
authorPJ Fanning <fanningpj@apache.org>
Fri, 14 May 2021 02:24:48 +0000 (02:24 +0000)
committerPJ Fanning <fanningpj@apache.org>
Fri, 14 May 2021 02:24:48 +0000 (02:24 +0000)
git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1889874 13f79535-47bb-0310-9956-ffa450edef68

poi-ooxml/src/main/java/org/apache/poi/xssf/usermodel/XSSFBuiltinTableStyle.java
poi-scratchpad/src/main/java/org/apache/poi/hslf/dev/PPTXMLDump.java
poi-scratchpad/src/main/java/org/apache/poi/hwpf/converter/WordToTextConverter.java
poi/src/main/java9/module-info.class
poi/src/test/java9/module-info.class

index 2ba065b766f93ffc20ffd9dd1ca7e474d88cb442..5e65241e46246a73a7d34bd42b1628f7b9903f77 100644 (file)
@@ -20,7 +20,6 @@ package org.apache.poi.xssf.usermodel;
 import java.io.ByteArrayInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.io.StringWriter;
 import java.nio.charset.StandardCharsets;
 import java.util.EnumMap;
 import java.util.Map;
@@ -31,6 +30,7 @@ import javax.xml.transform.TransformerException;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 
+import org.apache.commons.io.output.StringBuilderWriter;
 import org.apache.poi.ooxml.util.DocumentHelper;
 import org.apache.poi.ss.usermodel.DifferentialStyleProvider;
 import org.apache.poi.ss.usermodel.TableStyle;
@@ -428,7 +428,7 @@ public enum XSSFBuiltinTableStyle {
         // add a dummy node to adjust properly.
         dxfsNode.insertBefore(dxfsNode.getOwnerDocument().createElement("dxf"), dxfsNode.getFirstChild());
 
-        StringBuilder sb = new StringBuilder();
+        StringBuilder sb = new StringBuilder(1024);
         sb.append("<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?>\n")
                 .append("<styleSheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\" ")
                 .append("xmlns:mc=\"http://schemas.openxmlformats.org/markup-compatibility/2006\" ")
@@ -441,8 +441,8 @@ public enum XSSFBuiltinTableStyle {
         return sb.toString();
     }
 
-    private static String writeToString(Node node) throws IOException, TransformerException {
-        try (StringWriter sw = new StringWriter()){
+    private static String writeToString(Node node) throws TransformerException {
+        try (StringBuilderWriter sw = new StringBuilderWriter(1024)){
             Transformer transformer = XMLHelper.newTransformer();
             transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
             transformer.transform(new DOMSource(node), new StreamResult(sw));
index b15d37c987d3a8fe86f3b0cae4caf47fbb1c00e9..eba41158535e267908ab516d6639804696663104 100644 (file)
@@ -22,11 +22,11 @@ import java.io.FileOutputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.OutputStreamWriter;
-import java.io.StringWriter;
 import java.io.Writer;
 import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 
+import org.apache.commons.io.output.StringBuilderWriter;
 import org.apache.commons.io.output.UnsynchronizedByteArrayOutputStream;
 import org.apache.poi.hslf.record.RecordTypes;
 import org.apache.poi.hslf.usermodel.HSLFSlideShow;
@@ -214,7 +214,7 @@ public final class PPTXMLDump {
                     dump.dump(out);
                     out.close();
                 } else {
-                    StringWriter out = new StringWriter();
+                    StringBuilderWriter out = new StringBuilderWriter(1024);
                     dump.dump(out);
                     System.out.println(out);
                 }
index cebc55b743f7726664bf821fd3d7f283551e5bcc..ddd7ff68d586fac3772112b9902575bed2e0559d 100644 (file)
@@ -18,7 +18,6 @@ package org.apache.poi.hwpf.converter;
 
 import java.io.File;
 import java.io.IOException;
-import java.io.StringWriter;
 import java.lang.reflect.Method;
 import java.util.List;
 import java.util.concurrent.atomic.AtomicInteger;
@@ -30,6 +29,7 @@ import javax.xml.transform.Transformer;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamResult;
 
+import org.apache.commons.io.output.StringBuilderWriter;
 import org.apache.logging.log4j.LogManager;
 import org.apache.logging.log4j.Logger;
 import org.apache.poi.hpsf.SummaryInformation;
@@ -172,7 +172,7 @@ public class WordToTextConverter extends AbstractWordConverter
 
     public String getText() throws Exception
     {
-        StringWriter stringWriter = new StringWriter();
+        StringBuilderWriter stringWriter = new StringBuilderWriter(1024);
         DOMSource domSource = new DOMSource( getDocument() );
         StreamResult streamResult = new StreamResult( stringWriter );
 
index 65a7086587a0de967df019c649f7d2b63c78f1ad..86d7379bf9e5272942ed0321816af5e1e07b7203 100644 (file)
Binary files a/poi/src/main/java9/module-info.class and b/poi/src/main/java9/module-info.class differ
index 2cd1356efd514aad56ecd0f7d22b7bcf09ac416f..fabf8f27eda563fa84f9f568220345986b015bfb 100644 (file)
Binary files a/poi/src/test/java9/module-info.class and b/poi/src/test/java9/module-info.class differ