From 8f4d5d5f23fd45a88da1fc394475abe8b3e6f415 Mon Sep 17 00:00:00 2001 From: Yuichiro Hanada Date: Fri, 23 Aug 2013 22:39:36 +0900 Subject: [PATCH] Fix getDictionaryFileHeader. Change-Id: I5186f41b0f38eb08f4154f7b3de7ffc2119fc44b --- .../inputmethod/latin/makedict/BinaryDictIOUtils.java | 3 ++- .../inputmethod/latin/utils/DictionaryInfoUtils.java | 8 +------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java index 8dce1e9a4..323afb40a 100644 --- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java +++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictIOUtils.java @@ -517,7 +517,7 @@ public final class BinaryDictIOUtils { * @param offset The offset in the file where to start reading the data. * @param length The length of the data file. */ - public static FileHeader getDictionaryFileHeader( + private static FileHeader getDictionaryFileHeader( final File file, final long offset, final long length) throws FileNotFoundException, IOException, UnsupportedFormatException { final byte[] buffer = new byte[HEADER_READING_BUFFER_SIZE]; @@ -528,6 +528,7 @@ public final class BinaryDictIOUtils { throws FileNotFoundException, IOException { final FileInputStream inStream = new FileInputStream(file); try { + inStream.skip(offset); inStream.read(buffer); return new ByteArrayDictBuffer(buffer); } finally { diff --git a/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java b/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java index 34eccd65b..cec6dbab4 100644 --- a/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java +++ b/java/src/com/android/inputmethod/latin/utils/DictionaryInfoUtils.java @@ -281,13 +281,7 @@ public class DictionaryInfoUtils { } public static FileHeader getDictionaryFileHeaderOrNull(final File file) { - try { - return BinaryDictIOUtils.getDictionaryFileHeader(file, 0, file.length()); - } catch (UnsupportedFormatException e) { - return null; - } catch (IOException e) { - return null; - } + return BinaryDictIOUtils.getDictionaryFileHeaderOrNull(file, 0, file.length()); } private static DictionaryInfo createDictionaryInfoFromFileAddress(