| 38 | private String language; |
| 39 | |
| 40 | public Dictionary(final String filename) |
| 41 | throws DictionaryException { |
| 42 | |
| 43 | try { |
| 44 | this.file = new RandomReadingFile(filename); |
| 45 | // } catch (IOException e) { |
| 46 | } catch (Exception e) { |
| 47 | throw new DictionaryException(e.toString()); |
| 48 | } |
| 49 | |
| 50 | try { |
| 51 | /* |
| 52 | * Check magic number |
| 53 | */ |
| 54 | if (file.readInt() != MAGIC_NUMBER) { |
| 55 | throw new DictionaryException(); |
| 56 | } |
| 57 | |
| 58 | /* |
| 59 | * Read header |
| 60 | */ |
| 61 | title = file.readUTF(); |
| 62 | language = file.readUTF(); |
| 63 | indexPosition = file.readInt(); |
| 64 | } catch (Exception e) { |
| 65 | throw new DictionaryException("Dictionary is corrupted"); |
| 66 | } |
| 67 | } |
| 68 | |
| 69 | /** |
| 70 | * Loads the index |