diff options
author | 2012-10-23 17:14:12 +0900 | |
---|---|---|
committer | 2012-10-25 16:40:15 +0900 | |
commit | b3c98901c5fc1460b54cdf27d74405f27c88e74b (patch) | |
tree | 4b076617d541c97b05249c337b1aeb79980f0182 /java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java | |
parent | 77fe603a3d82f5fc28816520bac479ff48bf15e5 (diff) | |
download | latinime-b3c98901c5fc1460b54cdf27d74405f27c88e74b.tar.gz latinime-b3c98901c5fc1460b54cdf27d74405f27c88e74b.tar.xz latinime-b3c98901c5fc1460b54cdf27d74405f27c88e74b.zip |
Add auto detection and decoding of dictionary files. (A2)
Bug: 7388852
Change-Id: I25e755fc15f5b383acc046f668e9681efa4f0c2f
Diffstat (limited to 'java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java')
-rw-r--r-- | java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java b/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java index da5236974..031306e1d 100644 --- a/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java +++ b/java/src/com/android/inputmethod/latin/makedict/BinaryDictInputOutput.java @@ -1699,6 +1699,14 @@ public final class BinaryDictInputOutput { } /** + * Helper method to pass a file name instead of a File object to isBinaryDictionary. + */ + public static boolean isBinaryDictionary(final String filename) { + final File file = new File(filename); + return isBinaryDictionary(file); + } + + /** * Basic test to find out whether the file is a binary dictionary or not. * * Concretely this only tests the magic number. @@ -1706,10 +1714,9 @@ public final class BinaryDictInputOutput { * @param filename The name of the file to test. * @return true if it's a binary dictionary, false otherwise */ - public static boolean isBinaryDictionary(final String filename) { + public static boolean isBinaryDictionary(final File file) { FileInputStream inStream = null; try { - final File file = new File(filename); inStream = new FileInputStream(file); final ByteBuffer buffer = inStream.getChannel().map( FileChannel.MapMode.READ_ONLY, 0, file.length()); |