use StandardCharsets

git-svn-id: https://svn.apache.org/repos/asf/poi/trunk@1818629 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
PJ Fanning 2017-12-19 00:33:16 +00:00
parent 819eac1f82
commit 537badf156
3 changed files with 6 additions and 13 deletions

View File

@ -22,6 +22,7 @@ import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.nio.charset.StandardCharsets;
import java.util.Arrays; import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
@ -64,14 +65,7 @@ final class FunctionMetadataReader {
} }
try { try {
BufferedReader br; try(BufferedReader br = new BufferedReader(new InputStreamReader(is, StandardCharsets.UTF_8))) {
try {
br = new BufferedReader(new InputStreamReader(is,"UTF-8"));
} catch(UnsupportedEncodingException e) {
throw new RuntimeException(e);
}
try {
FunctionDataBuilder fdb = new FunctionDataBuilder(400); FunctionDataBuilder fdb = new FunctionDataBuilder(400);
while (true) { while (true) {
@ -90,8 +84,6 @@ final class FunctionMetadataReader {
} }
return fdb.build(); return fdb.build();
} finally {
br.close();
} }
} finally { } finally {
is.close(); is.close();

View File

@ -24,6 +24,7 @@ import java.io.InputStream;
import java.io.InputStreamReader; import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.nio.charset.StandardCharsets;
import java.util.Enumeration; import java.util.Enumeration;
import java.util.HashMap; import java.util.HashMap;
import java.util.Iterator; 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 { private static void copyStreamAndInjectWorksheet(InputStream in, OutputStream out, InputStream worksheetData) throws IOException {
InputStreamReader inReader=new InputStreamReader(in,"UTF-8"); InputStreamReader inReader = new InputStreamReader(in, StandardCharsets.UTF_8);
OutputStreamWriter outWriter=new OutputStreamWriter(out,"UTF-8"); OutputStreamWriter outWriter = new OutputStreamWriter(out, StandardCharsets.UTF_8);
boolean needsStartTag = true; boolean needsStartTag = true;
int c; int c;
int pos=0; int pos=0;

View File

@ -345,7 +345,7 @@ public final class TestOldExcelExtractor {
} finally { } finally {
out.close(); out.close();
} }
String string = new String(out.toByteArray(), "UTF-8"); String string = out.toString("UTF-8");
assertTrue("Had: " + string, assertTrue("Had: " + string,
string.contains("Table C-13--Lemons")); string.contains("Table C-13--Lemons"));
} finally { } finally {