]> gitweb.fperrin.net Git - Dictionary.git/commitdiff
Starting to do compression.
authorthadh <thadh@thadh-macbookpro>
Thu, 4 Oct 2012 15:08:29 +0000 (08:08 -0700)
committerthadh <thadh@thadh-macbookpro>
Thu, 4 Oct 2012 15:08:29 +0000 (08:08 -0700)
src/com/hughes/android/dictionary/engine/HtmlEntry.java

index 4412397e429f8b0bfde443fe2cc86a28d6017fd3..b70a9ed57cf79bc629bf55c6531dd3ed4f663e25 100644 (file)
@@ -28,13 +28,20 @@ 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 boolean compressed = raf.readBoolean();
+    final int length = raf.readInt();
+    final byte[] bytes = new byte[length];
+    raf.readFully(bytes);
+    html = new String(bytes, "UTF-8");
   }
   @Override
   public void write(RandomAccessFile raf) throws IOException {
     super.write(raf);
     raf.writeUTF(title);
-    raf.writeUTF(html);
+    raf.writeBoolean(false);
+    final byte[] bytes = html.getBytes("UTF-8");
+    raf.writeInt(bytes.length);
+    raf.write(bytes);
   }
 
   @Override