diff options
author | 2014-03-06 07:32:07 +0000 | |
---|---|---|
committer | 2014-03-06 07:32:07 +0000 | |
commit | d93eb680c463f6258f8b9e31bb379545b8679357 (patch) | |
tree | 0133f8580b2e85be2410b0f71759c2dd8521fe0c /java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java | |
parent | db38d5cf632e6e20178ca3bc1603eabd71c74d41 (diff) | |
parent | de36b47d29b7d6bdfb448a97bef2dcc3f5649205 (diff) | |
download | latinime-d93eb680c463f6258f8b9e31bb379545b8679357.tar.gz latinime-d93eb680c463f6258f8b9e31bb379545b8679357.tar.xz latinime-d93eb680c463f6258f8b9e31bb379545b8679357.zip |
Merge "Use BinaryDictionaryUtils to read dictionary header."
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. */ |