aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/java/org/apache/poi/ss/formula/function/FunctionMetadataReader.java12
-rw-r--r--src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java5
-rw-r--r--src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java2
3 files changed, 6 insertions, 13 deletions
diff --git a/src/java/org/apache/poi/ss/formula/function/FunctionMetadataReader.java b/src/java/org/apache/poi/ss/formula/function/FunctionMetadataReader.java
index e23275dbe3..feea7d7b45 100644
--- a/src/java/org/apache/poi/ss/formula/function/FunctionMetadataReader.java
+++ b/src/java/org/apache/poi/ss/formula/function/FunctionMetadataReader.java
@@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException;
+import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
@@ -64,14 +65,7 @@ final class FunctionMetadataReader {
}
try {
- BufferedReader br;
- try {
- br = new BufferedReader(new InputStreamReader(is,"UTF-8"));
- } catch(UnsupportedEncodingException e) {
- throw new RuntimeException(e);
- }
-
- try {
+ try(BufferedReader br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
FunctionDataBuilder fdb = new FunctionDataBuilder(400);
while (true) {
@@ -90,8 +84,6 @@ final class FunctionMetadataReader {
}
return fdb.build();
- } finally {
- br.close();
}
} finally {
is.close();
diff --git a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java
index 29b0bddab4..f65de2eb74 100644
--- a/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java
+++ b/src/ooxml/java/org/apache/poi/xssf/streaming/SXSSFWorkbook.java
@@ -24,6 +24,7 @@ import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
+import java.nio.charset.StandardCharsets;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Iterator;
@@ -394,8 +395,8 @@ public class SXSSFWorkbook implements Workbook {
}
private static void copyStreamAndInjectWorksheet(InputStream in, OutputStream out, InputStream worksheetData) throws IOException {
- InputStreamReader inReader=new InputStreamReader(in,"UTF-8");
- OutputStreamWriter outWriter=new OutputStreamWriter(out,"UTF-8");
+ InputStreamReader inReader = new InputStreamReader(in, StandardCharsets.UTF_8);
+ OutputStreamWriter outWriter = new OutputStreamWriter(out, StandardCharsets.UTF_8);
boolean needsStartTag = true;
int c;
int pos=0;
diff --git a/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java b/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java
index 659f769023..a07470d72d 100644
--- a/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java
+++ b/src/testcases/org/apache/poi/hssf/extractor/TestOldExcelExtractor.java
@@ -345,7 +345,7 @@ public final class TestOldExcelExtractor {
} finally {
out.close();
}
- String string = new String(out.toByteArray(), "UTF-8");
+ String string = out.toString("UTF-8");
assertTrue("Had: " + string,
string.contains("Table C-13--Lemons"));
} finally {