]> gitweb.fperrin.net Git - Dictionary.git/blobdiff - src/com/hughes/android/dictionary/engine/HtmlEntry.java
GZip HtmlEntry.
[Dictionary.git] / src / com / hughes / android / dictionary / engine / HtmlEntry.java
index 4412397e429f8b0bfde443fe2cc86a28d6017fd3..2284d2052b8535232b5b6fe63d20ff542d4c8b4e 100644 (file)
@@ -28,13 +28,23 @@ public class HtmlEntry extends AbstractEntry implements RAFSerializable<HtmlEntr
   public HtmlEntry(Dictionary dictionary, RandomAccessFile raf, final int index) throws IOException {
     super(dictionary, raf, index);
     title = raf.readUTF();
-    html = raf.readUTF();
+
+    final byte[] bytes = new byte[raf.readInt()];
+    final byte[] zipBytes = new byte[raf.readInt()];
+    raf.read(zipBytes);
+    StringUtil.unzipFully(zipBytes, bytes);
+    html = new String(bytes, "UTF-8");
   }
   @Override
   public void write(RandomAccessFile raf) throws IOException {
     super.write(raf);
     raf.writeUTF(title);
-    raf.writeUTF(html);
+
+    final byte[] bytes = html.getBytes("UTF-8");
+    final byte[] zipBytes = StringUtil.zipBytes(bytes);
+    raf.writeInt(bytes.length);
+    raf.writeInt(zipBytes.length);
+    raf.write(zipBytes);
   }
 
   @Override