aboutsummaryrefslogtreecommitdiffstats
path: root/poi-examples
diff options
context:
space:
mode:
Diffstat (limited to 'poi-examples')
-rw-r--r--poi-examples/src/main/java/org/apache/poi/examples/hsmf/Msg2txt.java3
-rw-r--r--poi-examples/src/main/java/org/apache/poi/examples/ss/html/ToHtml.java2
-rw-r--r--poi-examples/src/main/java/org/apache/poi/examples/xssf/usermodel/BigGridDemo.java6
-rw-r--r--poi-examples/src/test/java/org/apache/poi/integration/TestXLSX2CSV.java8
4 files changed, 10 insertions, 9 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");
}
diff --git a/poi-examples/src/test/java/org/apache/poi/integration/TestXLSX2CSV.java b/poi-examples/src/test/java/org/apache/poi/integration/TestXLSX2CSV.java
index 4d1a95444d..a9bed39008 100644
--- a/poi-examples/src/test/java/org/apache/poi/integration/TestXLSX2CSV.java
+++ b/poi-examples/src/test/java/org/apache/poi/integration/TestXLSX2CSV.java
@@ -42,7 +42,7 @@ public class TestXLSX2CSV {
// remember and replace default error streams
err = System.err;
- PrintStream error = new PrintStream(errorBytes, true, "UTF-8");
+ PrintStream error = new PrintStream(errorBytes, true, StandardCharsets.UTF_8.name());
System.setErr(error);
}
@@ -71,14 +71,14 @@ public class TestXLSX2CSV {
// returns with some System.err
XLSX2CSV.main(new String[] { "not-existing-file.xlsx" });
- String output = errorBytes.toString("UTF-8");
+ String output = errorBytes.toString(StandardCharsets.UTF_8);
assertTrue(output.contains("Not found or not a file: not-existing-file.xlsx"), "Had: " + output);
}
@Test
public void testSampleFile() throws Exception {
final UnsynchronizedByteArrayOutputStream outputBytes = new UnsynchronizedByteArrayOutputStream();
- PrintStream out = new PrintStream(outputBytes, true, "UTF-8");
+ PrintStream out = new PrintStream(outputBytes, true, StandardCharsets.UTF_8.name());
// The package open is instantaneous, as it should be.
try (OPCPackage p = OPCPackage.open(XSSFTestDataSamples.getSampleFile("sample.xlsx").getAbsolutePath(), PackageAccess.READ)) {
@@ -97,7 +97,7 @@ public class TestXLSX2CSV {
@Test
public void testMinColumns() throws Exception {
final UnsynchronizedByteArrayOutputStream outputBytes = new UnsynchronizedByteArrayOutputStream();
- PrintStream out = new PrintStream(outputBytes, true, "UTF-8");
+ PrintStream out = new PrintStream(outputBytes, true, StandardCharsets.UTF_8.name());
// The package open is instantaneous, as it should be.
try (OPCPackage p = OPCPackage.open(XSSFTestDataSamples.getSampleFile("sample.xlsx").getAbsolutePath(), PackageAccess.READ)) {