poi-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From fannin...@apache.org
Subject svn commit: r1818628 - in /poi/trunk/src: examples/src/org/apache/poi/hwpf/ integrationtest/org/apache/poi/stress/ java/org/apache/poi/poifs/crypt/ java/org/apache/poi/poifs/filesystem/ java/org/apache/poi/util/ ooxml/java/org/apache/poi/openxml4j/opc/...
Date Tue, 19 Dec 2017 00:23:52 GMT
Author: fanningpj
Date: Tue Dec 19 00:23:52 2017
New Revision: 1818628

URL: http://svn.apache.org/viewvc?rev=1818628&view=rev
Log:
use StandardCharsets

Modified:
    poi/trunk/src/examples/src/org/apache/poi/hwpf/Word2Forrest.java
    poi/trunk/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java
    poi/trunk/src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java
    poi/trunk/src/java/org/apache/poi/poifs/filesystem/FileMagic.java
    poi/trunk/src/java/org/apache/poi/util/HexDump.java
    poi/trunk/src/java/org/apache/poi/util/ReplacingInputStream.java
    poi/trunk/src/java/org/apache/poi/util/StringUtil.java
    poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java
    poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/binary/XSSFBUtils.java
    poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFBuiltinTableStyle.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestHxxFEncryption.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbookWithCustomZipEntrySource.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java
    poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/util/TestEvilUnclosedBRFixingInputStream.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkHeaderV11.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/HemfText.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/PPTXMLDump.java
    poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfFont.java

Modified: poi/trunk/src/examples/src/org/apache/poi/hwpf/Word2Forrest.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/examples/src/org/apache/poi/hwpf/Word2Forrest.java?rev=1818628&r1=1818627&r2=1818628&view=diff
==============================================================================
--- poi/trunk/src/examples/src/org/apache/poi/hwpf/Word2Forrest.java (original)
+++ poi/trunk/src/examples/src/org/apache/poi/hwpf/Word2Forrest.java Tue Dec 19 00:23:52 2017
@@ -24,7 +24,7 @@ import java.io.InputStream;
 import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.Writer;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.poi.hwpf.model.StyleDescription;
 import org.apache.poi.hwpf.model.StyleSheet;
@@ -40,7 +40,7 @@ public final class Word2Forrest
   @SuppressWarnings("unused")
   public Word2Forrest(HWPFDocument doc, OutputStream stream) throws IOException
   {
-      _out = new OutputStreamWriter (stream, Charset.forName("UTF-8"));
+      _out = new OutputStreamWriter (stream, StandardCharsets.UTF_8);
     _doc = doc;
 
     init ();

Modified: poi/trunk/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java?rev=1818628&r1=1818627&r2=1818628&view=diff
==============================================================================
--- poi/trunk/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java (original)
+++ poi/trunk/src/integrationtest/org/apache/poi/stress/HPSFFileHandler.java Tue Dec 19 00:23:52
2017
@@ -24,7 +24,7 @@ import java.io.FileInputStream;
 import java.io.IOException;
 import java.io.InputStream;
 import java.io.PrintStream;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.Collections;
 import java.util.HashSet;
@@ -110,7 +110,7 @@ public class HPSFFileHandler extends POI
         try {
             System.setOut(psNew);
             CopyCompare.main(new String[]{file.getAbsolutePath(), copyOutput.getAbsolutePath()});
-            assertEquals("Equal" + NL, new String(bos.toByteArray(), Charset.forName("UTF-8")));
+            assertEquals("Equal" + NL, new String(bos.toByteArray(), StandardCharsets.UTF_8));
         } finally {
             System.setOut(ps);
         }

Modified: poi/trunk/src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java?rev=1818628&r1=1818627&r2=1818628&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/crypt/DataSpaceMapUtils.java Tue Dec 19 00:23:52
2017
@@ -18,7 +18,7 @@
 package org.apache.poi.poifs.crypt;
 
 import java.io.IOException;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.poi.EncryptedDocumentException;
 import org.apache.poi.poifs.crypt.standard.EncryptionRecord;
@@ -352,7 +352,7 @@ public class DataSpaceMapUtils {
             }
         }
 
-        return new String(data, 0, data.length, Charset.forName("UTF-8"));
+        return new String(data, 0, data.length, StandardCharsets.UTF_8);
     }
     
     public static void writeUtf8LPP4(LittleEndianOutput os, String str) {
@@ -360,7 +360,7 @@ public class DataSpaceMapUtils {
             os.writeInt(str == null ? 0 : 4);
             os.writeInt(0);
         } else {
-            byte buf[] = str.getBytes(Charset.forName("UTF-8"));
+            byte buf[] = str.getBytes(StandardCharsets.UTF_8);
             os.writeInt(buf.length);
             os.write(buf);
             int scratchBytes = buf.length%4;

Modified: poi/trunk/src/java/org/apache/poi/poifs/filesystem/FileMagic.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/poifs/filesystem/FileMagic.java?rev=1818628&r1=1818627&r2=1818628&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/poifs/filesystem/FileMagic.java (original)
+++ poi/trunk/src/java/org/apache/poi/poifs/filesystem/FileMagic.java Tue Dec 19 00:23:52
2017
@@ -19,11 +19,11 @@ package org.apache.poi.poifs.filesystem;
 
 import static org.apache.poi.poifs.common.POIFSConstants.OOXML_FILE_HEADER;
 import static org.apache.poi.poifs.common.POIFSConstants.RAW_XML_FILE_HEADER;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.io.BufferedInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.nio.charset.Charset;
 
 import org.apache.poi.poifs.storage.HeaderBlockConstants;
 import org.apache.poi.util.IOUtils;
@@ -76,7 +76,7 @@ public enum FileMagic {
     /** PDF document */
     PDF("%PDF"),
     /** Some different HTML documents */
-    HTML("<!DOCTYP".getBytes(Charset.forName("UTF-8")), "<html".getBytes(Charset.forName("UTF-8"))),
+    HTML("<!DOCTYP".getBytes(UTF_8), "<html".getBytes(UTF_8)),
     // keep UNKNOWN always as last enum!
     /** UNKNOWN magic */
     UNKNOWN(new byte[0]);

Modified: poi/trunk/src/java/org/apache/poi/util/HexDump.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/HexDump.java?rev=1818628&r1=1818627&r2=1818628&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/HexDump.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/HexDump.java Tue Dec 19 00:23:52 2017
@@ -25,8 +25,7 @@ import java.io.OutputStream;
 import java.io.OutputStreamWriter;
 import java.io.PrintStream;
 import java.nio.charset.Charset;
-
-import org.apache.commons.codec.CharEncoding;
+import java.nio.charset.StandardCharsets;
 
 /**
  * dump data in hexadecimal format
@@ -34,7 +33,7 @@ import org.apache.commons.codec.CharEnco
 @Internal
 public class HexDump {
     public static final String EOL = System.getProperty("line.separator");
-    public static final Charset UTF8 = Charset.forName(CharEncoding.UTF_8);
+    public static final Charset UTF8 = StandardCharsets.UTF_8;
 
     private HexDump() {
         // all static methods, so no need for a public constructor

Modified: poi/trunk/src/java/org/apache/poi/util/ReplacingInputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/ReplacingInputStream.java?rev=1818628&r1=1818627&r2=1818628&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/ReplacingInputStream.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/ReplacingInputStream.java Tue Dec 19 00:23:52 2017
@@ -17,10 +17,11 @@
 
 package org.apache.poi.util;
 
+import static java.nio.charset.StandardCharsets.UTF_8;
+
 import java.io.FilterInputStream;
 import java.io.IOException;
 import java.io.InputStream;
-import java.nio.charset.Charset;
 import java.util.Arrays;
 
 /**
@@ -51,8 +52,6 @@ public class ReplacingInputStream extend
         UNBUFFER
     }
 
-    private static final Charset UTF8 = Charset.forName("UTF-8");
-
     /**
      * Replace occurrences of pattern in the input. Note: input is assumed to be UTF-8 encoded.
If not the case use byte[] based pattern and replacement.
      * @param in input
@@ -60,7 +59,7 @@ public class ReplacingInputStream extend
      * @param replacement the replacement or null
      */
     public ReplacingInputStream(InputStream in, String pattern, String replacement) {
-        this(in, pattern.getBytes(UTF8), replacement==null ? null : replacement.getBytes(UTF8));
+        this(in, pattern.getBytes(UTF_8), replacement==null ? null : replacement.getBytes(UTF_8));
     }
 
     /**

Modified: poi/trunk/src/java/org/apache/poi/util/StringUtil.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/java/org/apache/poi/util/StringUtil.java?rev=1818628&r1=1818627&r2=1818628&view=diff
==============================================================================
--- poi/trunk/src/java/org/apache/poi/util/StringUtil.java (original)
+++ poi/trunk/src/java/org/apache/poi/util/StringUtil.java Tue Dec 19 00:23:52 2017
@@ -18,6 +18,7 @@
 package org.apache.poi.util;
 
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.HashMap;
 import java.util.Iterator;
 import java.util.Locale;
@@ -28,12 +29,12 @@ import java.util.Map;
  */
 @Internal
 public class StringUtil {
-    protected static final Charset ISO_8859_1 = Charset.forName("ISO-8859-1");
+    protected static final Charset ISO_8859_1 = StandardCharsets.ISO_8859_1;
     //arbitrarily selected; may need to increase
     private static final int MAX_RECORD_LENGTH = 10000000;
 
-    public static final Charset UTF16LE = Charset.forName("UTF-16LE");
-    public static final Charset UTF8 = Charset.forName("UTF-8");
+    public static final Charset UTF16LE = StandardCharsets.UTF_16LE;
+    public static final Charset UTF8 = StandardCharsets.UTF_8;
     public static final Charset WIN_1252 = Charset.forName("cp1252");
     public static final Charset BIG5 = Charset.forName("Big5");
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java?rev=1818628&r1=1818627&r2=1818628&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/openxml4j/opc/PackagingURIHelper.java Tue Dec
19 00:23:52 2017
@@ -20,7 +20,7 @@ package org.apache.poi.openxml4j.opc;
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.nio.ByteBuffer;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.regex.Pattern;
 
 import org.apache.poi.openxml4j.exceptions.InvalidFormatException;
@@ -747,7 +747,7 @@ public final class PackagingURIHelper {
         int n = s.length();
         if (n == 0) return s;
 
-        ByteBuffer bb  = ByteBuffer.wrap(s.getBytes(Charset.forName("UTF-8")));
+        ByteBuffer bb  = ByteBuffer.wrap(s.getBytes(StandardCharsets.UTF_8));
         StringBuilder sb = new StringBuilder();
         while (bb.hasRemaining()) {
             int b = bb.get() & 0xff;

Modified: poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java?rev=1818628&r1=1818627&r2=1818628&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java
(original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/poifs/crypt/dsig/services/TSPTimeStampService.java
Tue Dec 19 00:23:52 2017
@@ -33,7 +33,7 @@ import java.net.InetAddress;
 import java.net.InetSocketAddress;
 import java.net.Proxy;
 import java.net.URL;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.security.MessageDigest;
 import java.security.SecureRandom;
 import java.security.cert.X509Certificate;
@@ -129,7 +129,7 @@ public class TSPTimeStampService impleme
         
         if (signatureConfig.getTspUser() != null) {
             String userPassword = signatureConfig.getTspUser() + ":" + signatureConfig.getTspPass();
-            String encoding = DatatypeConverter.printBase64Binary(userPassword.getBytes(Charset.forName("iso-8859-1")));
+            String encoding = DatatypeConverter.printBase64Binary(userPassword.getBytes(StandardCharsets.ISO_8859_1));
             huc.setRequestProperty("Authorization", "Basic " + encoding);
         }
 

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/binary/XSSFBUtils.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/binary/XSSFBUtils.java?rev=1818628&r1=1818627&r2=1818628&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/binary/XSSFBUtils.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/binary/XSSFBUtils.java Tue Dec 19 00:23:52
2017
@@ -18,7 +18,7 @@
 package org.apache.poi.xssf.binary;
 
 
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.poi.POIXMLException;
 import org.apache.poi.util.Internal;
@@ -54,7 +54,7 @@ public class XSSFBUtils {
             throw new XSSFBParseException("trying to read beyond data length:" +
              "offset="+offset+", numBytes="+numBytes+", data.length="+data.length);
         }
-        sb.append(new String(data, offset, numBytes, Charset.forName("UTF-16LE")));
+        sb.append(new String(data, offset, numBytes, StandardCharsets.UTF_16LE));
         numBytes+=4;
         return numBytes;
     }
@@ -80,7 +80,7 @@ public class XSSFBUtils {
         if (offset+numBytes > data.length) {
             throw new XSSFBParseException("trying to read beyond data length");
         }
-        sb.append(new String(data, offset, numBytes, Charset.forName("UTF-16LE")));
+        sb.append(new String(data, offset, numBytes, StandardCharsets.UTF_16LE));
         numBytes+=4;
         return numBytes;
     }

Modified: poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFBuiltinTableStyle.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFBuiltinTableStyle.java?rev=1818628&r1=1818627&r2=1818628&view=diff
==============================================================================
--- poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFBuiltinTableStyle.java (original)
+++ poi/trunk/src/ooxml/java/org/apache/poi/xssf/usermodel/XSSFBuiltinTableStyle.java Tue
Dec 19 00:23:52 2017
@@ -19,7 +19,7 @@ package org.apache.poi.xssf.usermodel;
 
 import java.io.ByteArrayInputStream;
 import java.io.InputStream;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.EnumMap;
 import java.util.Map;
 
@@ -403,7 +403,7 @@ public enum XSSFBuiltinTableStyle {
                     // hack because I can't figure out how to get XMLBeans to parse a sub-element
in a standalone manner
                     // - build a fake styles.xml file with just this built-in
                     StylesTable styles = new StylesTable();
-                    styles.readFrom(new ByteArrayInputStream(styleXML(dxfsNode, tableStyleNode).getBytes(Charset.forName("UTF-8"))));
+                    styles.readFrom(new ByteArrayInputStream(styleXML(dxfsNode, tableStyleNode).getBytes(StandardCharsets.UTF_8)));
                     styleMap.put(builtIn, new XSSFBuiltinTypeStyleStyle(builtIn, styles.getExplicitTableStyle(styleName)));
                 }
             } finally {

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestHxxFEncryption.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestHxxFEncryption.java?rev=1818628&r1=1818627&r2=1818628&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestHxxFEncryption.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/poifs/crypt/TestHxxFEncryption.java Tue Dec
19 00:23:52 2017
@@ -28,7 +28,7 @@ import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.File;
 import java.io.IOException;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.Arrays;
 import java.util.Collection;
 
@@ -94,7 +94,7 @@ public class TestHxxFEncryption {
     }
 
     private static String x(String base64) throws IOException {
-        return new String(RawDataUtil.decompress(base64), Charset.forName("UTF-8"));
+        return new String(RawDataUtil.decompress(base64), StandardCharsets.UTF_8);
     }
     
     @Test

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbookWithCustomZipEntrySource.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbookWithCustomZipEntrySource.java?rev=1818628&r1=1818627&r2=1818628&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbookWithCustomZipEntrySource.java
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/streaming/TestSXSSFWorkbookWithCustomZipEntrySource.java
Tue Dec 19 00:23:52 2017
@@ -22,6 +22,7 @@ package org.apache.poi.xssf.streaming;
 import static org.junit.Assert.assertEquals;
 import static org.junit.Assert.assertFalse;
 import static org.junit.Assert.assertTrue;
+import static java.nio.charset.StandardCharsets.UTF_8;
 
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
@@ -102,11 +103,6 @@ public final class TestSXSSFWorkbookWith
         opc.close();
     }
     
-    // Java 7 and above:
-    // import static java.nio.charset.StandardCharsets.UTF_8;
-    // Java 6 and below:
-    private static final Charset UTF_8 = Charset.forName("UTF-8");
-    
     @Test
     public void validateTempFilesAreEncrypted() throws IOException {
         TempFileRecordingSXSSFWorkbookWithCustomZipEntrySource workbook = new TempFileRecordingSXSSFWorkbookWithCustomZipEntrySource();

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java?rev=1818628&r1=1818627&r2=1818628&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java (original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/usermodel/TestUnfixedBugs.java Tue Dec
19 00:23:52 2017
@@ -23,11 +23,8 @@ import static org.junit.Assert.assertNul
 import static org.junit.Assert.assertTrue;
 
 import java.io.ByteArrayOutputStream;
-import java.io.File;
-import java.io.FileOutputStream;
 import java.io.IOException;
-import java.io.OutputStream;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 import java.util.Calendar;
 import java.util.Date;
 
@@ -86,7 +83,7 @@ public final class TestUnfixedBugs {
     private void verifyBug54084Unicode(Workbook wb) {
         // expected data is stored in UTF-8 in a text-file
         byte data[] = HSSFTestDataSamples.getTestDataFileContent("54084 - Greek - beyond
BMP.txt");
-        String testData = new String(data, Charset.forName("UTF-8")).trim();
+        String testData = new String(data, StandardCharsets.UTF_8).trim();
 
         Sheet sheet = wb.getSheetAt(0);
         Row row = sheet.getRow(0);

Modified: poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/util/TestEvilUnclosedBRFixingInputStream.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/util/TestEvilUnclosedBRFixingInputStream.java?rev=1818628&r1=1818627&r2=1818628&view=diff
==============================================================================
--- poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/util/TestEvilUnclosedBRFixingInputStream.java
(original)
+++ poi/trunk/src/ooxml/testcases/org/apache/poi/xssf/util/TestEvilUnclosedBRFixingInputStream.java
Tue Dec 19 00:23:52 2017
@@ -22,7 +22,7 @@ import static org.junit.Assert.assertArr
 import java.io.ByteArrayInputStream;
 import java.io.ByteArrayOutputStream;
 import java.io.IOException;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.poi.util.IOUtils;
 import org.apache.poi.util.ReplacingInputStream;
@@ -89,6 +89,6 @@ public final class TestEvilUnclosedBRFix
     }
 
     private static byte[] getBytes(String str) {
-        return str.getBytes(Charset.forName("UTF-8"));
+        return str.getBytes(StandardCharsets.UTF_8);
     }
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkHeaderV11.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkHeaderV11.java?rev=1818628&r1=1818627&r2=1818628&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkHeaderV11.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hdgf/chunks/ChunkHeaderV11.java Tue Dec 19
00:23:52 2017
@@ -18,6 +18,7 @@
 package org.apache.poi.hdgf.chunks;
 
 import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 /**
  * A chunk header from v11+
@@ -62,6 +63,6 @@ public final class ChunkHeaderV11 extend
 
     @Override
     public Charset getChunkCharset() {
-        return Charset.forName("UTF-16LE");
+        return StandardCharsets.UTF_16LE;
     }
 }

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/HemfText.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/HemfText.java?rev=1818628&r1=1818627&r2=1818628&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/HemfText.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hemf/record/HemfText.java Tue Dec 19 00:23:52
2017
@@ -17,6 +17,7 @@
 
 package org.apache.poi.hemf.record;
 
+import static java.nio.charset.StandardCharsets.UTF_16LE;
 
 import java.io.ByteArrayInputStream;
 import java.io.EOFException;
@@ -39,7 +40,6 @@ import org.apache.poi.util.RecordFormatE
 @Internal
 public class HemfText {
 
-    private static final Charset UTF16LE = Charset.forName("UTF-16LE");
     private static final int MAX_RECORD_LENGTH = 1_000_000;
 
     public static class ExtCreateFontIndirectW extends UnimplementedHemfRecord {
@@ -162,11 +162,11 @@ public class HemfText {
 
         @Override
         protected Charset getEncodingHint() {
-            return UTF16LE;
+            return UTF_16LE;
         }
 
         public String getText() throws IOException {
-            return getText(UTF16LE);
+            return getText(UTF_16LE);
         }
     }
 

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/PPTXMLDump.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/PPTXMLDump.java?rev=1818628&r1=1818627&r2=1818628&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/PPTXMLDump.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hslf/dev/PPTXMLDump.java Tue Dec 19 00:23:52
2017
@@ -25,7 +25,7 @@ import java.io.InputStream;
 import java.io.OutputStreamWriter;
 import java.io.StringWriter;
 import java.io.Writer;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.poi.hslf.record.RecordTypes;
 import org.apache.poi.hslf.usermodel.HSLFSlideShow;
@@ -212,7 +212,7 @@ public final class PPTXMLDump {
 
                 if (outFile){
                     FileOutputStream fos = new FileOutputStream(ppt.getName() + ".xml");
-                    OutputStreamWriter out = new OutputStreamWriter(fos, Charset.forName("UTF8"));
+                    OutputStreamWriter out = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
                     dump.dump(out);
                     out.close();
                 } else {

Modified: poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfFont.java
URL: http://svn.apache.org/viewvc/poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfFont.java?rev=1818628&r1=1818627&r2=1818628&view=diff
==============================================================================
--- poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfFont.java (original)
+++ poi/trunk/src/scratchpad/src/org/apache/poi/hwmf/record/HwmfFont.java Tue Dec 19 00:23:52
2017
@@ -18,7 +18,7 @@
 package org.apache.poi.hwmf.record;
 
 import java.io.IOException;
-import java.nio.charset.Charset;
+import java.nio.charset.StandardCharsets;
 
 import org.apache.poi.common.usermodel.fonts.FontCharset;
 import org.apache.poi.common.usermodel.fonts.FontFamily;
@@ -369,7 +369,7 @@ public class HwmfFont implements FontInf
             buf[readBytes++] = b = leis.readByte();
         } while (b != 0 && b != -1 && readBytes <= 32);
         
-        facename = new String(buf, 0, readBytes-1, Charset.forName("ISO-8859-1"));
+        facename = new String(buf, 0, readBytes-1, StandardCharsets.ISO_8859_1);
         
         return 5*LittleEndianConsts.SHORT_SIZE+8*LittleEndianConsts.BYTE_SIZE+readBytes;
     }



---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@poi.apache.org
For additional commands, e-mail: commits-help@poi.apache.org


Mime
View raw message