X-Git-Url: http://gitweb.fperrin.net/?a=blobdiff_plain;f=src%2Fcom%2Fhughes%2Fandroid%2Fdictionary%2Fengine%2FHtmlEntry.java;h=59ed59b3c54c08004308a7b8559f2298aca820fc;hb=8674b09eae371994e01e0af541b546fced86c366;hp=1a602a017ad8d8a0c59a511a5656efe4fb5ff958;hpb=3ce0dd16e69302365d3bc802f298a5388b293d86;p=Dictionary.git diff --git a/src/com/hughes/android/dictionary/engine/HtmlEntry.java b/src/com/hughes/android/dictionary/engine/HtmlEntry.java index 1a602a0..59ed59b 100644 --- a/src/com/hughes/android/dictionary/engine/HtmlEntry.java +++ b/src/com/hughes/android/dictionary/engine/HtmlEntry.java @@ -1,23 +1,21 @@ package com.hughes.android.dictionary.engine; -import android.support.annotation.NonNull; - -import com.hughes.util.StringUtil; -import com.hughes.util.raf.RAFListSerializer; -import com.hughes.util.raf.RAFListSerializerSkippable; -import com.ibm.icu.text.Transliterator; - import java.io.DataInput; import java.io.DataOutput; import java.io.IOException; 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; +import com.hughes.util.StringUtil; +import com.hughes.util.raf.RAFListSerializer; +import com.hughes.util.raf.RAFListSerializerSkippable; +import com.ibm.icu.text.Transliterator; + public class HtmlEntry extends AbstractEntry implements Comparable { // Title is not HTML escaped. @@ -46,7 +44,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); } @@ -139,7 +137,7 @@ public class HtmlEntry extends AbstractEntry implements Comparable { } @Override - public int compareTo(@NonNull HtmlEntry another) { + public int compareTo(/*@NonNull*/ HtmlEntry another) { if (title.compareTo(another.title) != 0) { return title.compareTo(another.title); } @@ -266,11 +264,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; } @@ -287,7 +281,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); }