diff options
author | 2014-03-05 19:42:53 +0900 | |
---|---|---|
committer | 2014-03-05 19:42:53 +0900 | |
commit | de36b47d29b7d6bdfb448a97bef2dcc3f5649205 (patch) | |
tree | 53466873e0dc5ef3802d3fd67a9fcf78a22cbc12 /java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java | |
parent | e784148ae6872942434eaa55ca32b4c6442cc8e8 (diff) | |
download | latinime-de36b47d29b7d6bdfb448a97bef2dcc3f5649205.tar.gz latinime-de36b47d29b7d6bdfb448a97bef2dcc3f5649205.tar.xz latinime-de36b47d29b7d6bdfb448a97bef2dcc3f5649205.zip |
Use BinaryDictionaryUtils to read dictionary header.
Bug: 8187060
Bug:13035567
Change-Id: I90a5e0665c367f5a1bd786f4babf0d03e79e68fa
Diffstat (limited to 'java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java index 90e7400fb..caf3cf354 100644 --- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java +++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java @@ -222,54 +222,6 @@ public final class BinaryDictIOUtils { return countSize; } - private static final int HEADER_READING_BUFFER_SIZE = 16384; - /** - * Convenience method to read the header of a binary file. - * - * This is quite resource intensive - don't call when performance is critical. - * - * @param file The file to read. - * @param offset The offset in the file where to start reading the data. - * @param length The length of the data file. - * @return the header of the specified dictionary file. - */ - private static DictionaryHeader getDictionaryFileHeader( - final File file, final long offset, final long length) - throws FileNotFoundException, IOException, UnsupportedFormatException { - final byte[] buffer = new byte[HEADER_READING_BUFFER_SIZE]; - final DictDecoder dictDecoder = FormatSpec.getDictDecoder(file, offset, length, - new DictDecoder.DictionaryBufferFactory() { - @Override - public DictBuffer getDictionaryBuffer(File file) - throws FileNotFoundException, IOException { - final FileInputStream inStream = new FileInputStream(file); - try { - inStream.skip(offset); - inStream.read(buffer); - return new ByteArrayDictBuffer(buffer); - } finally { - inStream.close(); - } - } - }); - if (dictDecoder == null) { - return null; - } - return dictDecoder.readHeader(); - } - - public static DictionaryHeader getDictionaryFileHeaderOrNull(final File file, final long offset, - final long length) { - try { - final DictionaryHeader header = getDictionaryFileHeader(file, offset, length); - return header; - } catch (UnsupportedFormatException e) { - return null; - } catch (IOException e) { - return null; - } - } - /** * Helper method to hide the actual value of the no children address. */ |