X-Git-Url: https://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Fcom%2Fhughes%2Fandroid%2Fdictionary%2Fengine%2FHtmlEntry.java;h=f279a3d8f8fa14071dd89bd2ba29d86c8ba15a23;hb=e79165503392ed6a7cb7a8eadc15eaae0cda9443;hp=8dcf905175f5f5e01b983a7fd288f2a80a998ae1;hpb=9d8da9938cc888948a65098aefa441c7a59c8459;p=Dictionary.git diff --git a/src/com/hughes/android/dictionary/engine/HtmlEntry.java b/src/com/hughes/android/dictionary/engine/HtmlEntry.java index 8dcf905..f279a3d 100644 --- a/src/com/hughes/android/dictionary/engine/HtmlEntry.java +++ b/src/com/hughes/android/dictionary/engine/HtmlEntry.java @@ -13,6 +13,7 @@ import java.io.PrintStream; import java.io.UnsupportedEncodingException; import java.lang.ref.SoftReference; import java.nio.channels.FileChannel; +import java.nio.charset.StandardCharsets; import java.util.List; import java.util.regex.Pattern; @@ -44,7 +45,7 @@ public class HtmlEntry extends AbstractEntry implements Comparable { } private void writeData(DataOutput raf) throws IOException { - final byte[] bytes = getHtml().getBytes("UTF-8"); + final byte[] bytes = getHtml().getBytes(StandardCharsets.UTF_8); StringUtil.writeVarInt(raf, bytes.length); raf.write(bytes); } @@ -264,11 +265,7 @@ public class HtmlEntry extends AbstractEntry implements Comparable { return html; } if (data != null) { - try { - html = new String(data.get(index), "UTF-8"); - } catch (UnsupportedEncodingException e) { - throw new RuntimeException("Dictionary HTML data corrupted", e); - } + html = new String(data.get(index), StandardCharsets.UTF_8); htmlRef = new SoftReference<>(html); return html; } @@ -285,7 +282,7 @@ public class HtmlEntry extends AbstractEntry implements Comparable { } try { final byte[] bytes = StringUtil.unzipFully(zipBytes, numBytes); - html = new String(bytes, "UTF-8"); + html = new String(bytes, StandardCharsets.UTF_8); } catch (IOException e) { throw new RuntimeException("Dictionary HTML data corrupted", e); }