diff options
author | 2014-03-05 23:34:14 -0800 | |
---|---|---|
committer | 2014-03-05 23:34:14 -0800 | |
commit | 2cb31a0f23863e59ebffbe590712016fd6f88ec9 (patch) | |
tree | 0133f8580b2e85be2410b0f71759c2dd8521fe0c /java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java | |
parent | ea3c70ebe21e6dacab9ec99c44d85d6d40b8a3d7 (diff) | |
parent | d93eb680c463f6258f8b9e31bb379545b8679357 (diff) | |
download | latinime-2cb31a0f23863e59ebffbe590712016fd6f88ec9.tar.gz latinime-2cb31a0f23863e59ebffbe590712016fd6f88ec9.tar.xz latinime-2cb31a0f23863e59ebffbe590712016fd6f88ec9.zip |
am d93eb680: Merge "Use BinaryDictionaryUtils to read dictionary header."
* commit 'd93eb680c463f6258f8b9e31bb379545b8679357':
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. */ |