From 87ee700d04af1fea764c0762f0fb5dada4411295 Mon Sep 17 00:00:00 2001 From: PJ Fanning Date: Fri, 15 Jul 2022 21:52:32 +0000 Subject: [github-340] make more use of StandardCharsets. Thanks to XenoAmess. This closes #340 git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1902755 13f79535-47bb-0310-9956-ffa450edef68 --- .../src/main/java/org/apache/poi/examples/hsmf/Msg2txt.java | 3 ++- .../src/main/java/org/apache/poi/examples/ss/html/ToHtml.java | 2 +- .../java/org/apache/poi/examples/xssf/usermodel/BigGridDemo.java | 6 +++--- 3 files changed, 6 insertions(+), 5 deletions(-) (limited to 'poi-examples/src/main/java') diff --git a/poi-examples/src/main/java/org/apache/poi/examples/hsmf/Msg2txt.java b/poi-examples/src/main/java/org/apache/poi/examples/hsmf/Msg2txt.java index 54dd9a279e..151cfc6fa0 100644 --- a/poi-examples/src/main/java/org/apache/poi/examples/hsmf/Msg2txt.java +++ b/poi-examples/src/main/java/org/apache/poi/examples/hsmf/Msg2txt.java @@ -22,6 +22,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; +import java.nio.charset.StandardCharsets; import org.apache.poi.hsmf.MAPIMessage; import org.apache.poi.hsmf.datatypes.AttachmentChunks; @@ -62,7 +63,7 @@ public class Msg2txt { public void processMessage() throws IOException { String txtFileName = fileNameStem + ".txt"; String attDirName = fileNameStem + "-att"; - try (PrintWriter txtOut = new PrintWriter(txtFileName, "UTF-8")) { + try (PrintWriter txtOut = new PrintWriter(txtFileName, StandardCharsets.UTF_8.name())) { try { String displayFrom = msg.getDisplayFrom(); txtOut.println("From: " + displayFrom); diff --git a/poi-examples/src/main/java/org/apache/poi/examples/ss/html/ToHtml.java b/poi-examples/src/main/java/org/apache/poi/examples/ss/html/ToHtml.java index 5097f34e98..cf9eeaf5c0 100644 --- a/poi-examples/src/main/java/org/apache/poi/examples/ss/html/ToHtml.java +++ b/poi-examples/src/main/java/org/apache/poi/examples/ss/html/ToHtml.java @@ -190,7 +190,7 @@ public final class ToHtml { return; } - try (PrintWriter pw = new PrintWriter(args[1], "UTF-8")) { + try (PrintWriter pw = new PrintWriter(args[1], StandardCharsets.UTF_8.name())) { ToHtml toHtml = create(args[0], pw); toHtml.setCompleteHTML(true); toHtml.printPage(); diff --git a/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/BigGridDemo.java b/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/BigGridDemo.java index f73e25a2c2..f0562be0b8 100644 --- a/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/BigGridDemo.java +++ b/poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/BigGridDemo.java @@ -25,6 +25,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.Writer; +import java.nio.charset.StandardCharsets; import java.util.Calendar; import java.util.Enumeration; import java.util.HashMap; @@ -77,7 +78,6 @@ import org.apache.poi.xssf.usermodel.XSSFWorkbook; */ public final class BigGridDemo { private static final Logger LOG = LogManager.getLogger(BigGridDemo.class); - private static final String XML_ENCODING = "UTF-8"; private static final Random rnd = new Random(); @@ -105,7 +105,7 @@ public final class BigGridDemo { tmp = TempFile.createTempFile("sheet", ".xml"); try ( FileOutputStream stream = new FileOutputStream(tmp); - Writer fw = new OutputStreamWriter(stream, XML_ENCODING) + Writer fw = new OutputStreamWriter(stream, StandardCharsets.UTF_8) ) { generate(fw, styles); } @@ -247,7 +247,7 @@ public final class BigGridDemo { } void beginSheet() throws IOException { - _out.write("" + + _out.write("" + "" ); _out.write("\n"); } -- cgit v1.2.3