diff options
Diffstat (limited to 'poi-examples/src/main/java')
3 files changed, 6 insertions, 5 deletions
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("<?xml version=\"1.0\" encoding=\""+XML_ENCODING+"\"?>" + + _out.write("<?xml version=\"1.0\" encoding=\"UTF-8\"?>" + "<worksheet xmlns=\"http://schemas.openxmlformats.org/spreadsheetml/2006/main\">" ); _out.write("<sheetData>\n"); } |