private void readDictionaryFile(final String dictionaryName) throws IOException, MissingResourceException { BufferedInputStream in; try { in = (BufferedInputStream) AccessController.doPrivileged( new PrivilegedExceptionAction() { public Object run() throws Exception { return new BufferedInputStream( getClass().getResourceAsStream("/sun/text/resources/" + dictionaryName)); } }); } catch (PrivilegedActionException e) { throw new InternalError(e.toString()); } byte[] buf = new byte[8]; if (in.read(buf) != 8) { throw new MissingResourceException("Wrong data length", dictionaryName, ""); } // check vesion int version = BreakIterator.getInt(buf, 0); if (version != supportedVersion) { throw new MissingResourceException( "Dictionary version(" + version + ") is unsupported", dictionaryName, ""); } // get data size int len = BreakIterator.getInt(buf, 4); buf = new byte[len]; if (in.read(buf) != len) { throw new MissingResourceException("Wrong data length", dictionaryName, ""); } // close the stream in.close(); int l; int offset = 0; // read in the column map for BMP characteres (this is serialized in // its internal form: an index array followed by a data array) l = BreakIterator.getInt(buf, offset); offset += 4; short[] temp = new short[l]; for (int i = 0; i < l; i++, offset += 2) { temp[i] = BreakIterator.getShort(buf, offset); } l = BreakIterator.getInt(buf, offset); offset += 4; byte[] temp2 = new byte[l]; for (int i = 0; i < l; i++, offset++) { temp2[i] = buf[offset]; } columnMap = new CompactByteArray(temp, temp2); // read in numCols and numColGroups numCols = BreakIterator.getInt(buf, offset); offset += 4; numColGroups = BreakIterator.getInt(buf, offset); offset += 4; // read in the row-number index l = BreakIterator.getInt(buf, offset); offset += 4; rowIndex = new short[l]; for (int i = 0; i < l; i++, offset += 2) { rowIndex[i] = BreakIterator.getShort(buf, offset); } // load in the populated-cells bitmap: index first, then bitmap list l = BreakIterator.getInt(buf, offset); offset += 4; rowIndexFlagsIndex = new short[l]; for (int i = 0; i < l; i++, offset += 2) { rowIndexFlagsIndex[i] = BreakIterator.getShort(buf, offset); } l = BreakIterator.getInt(buf, offset); offset += 4; rowIndexFlags = new int[l]; for (int i = 0; i < l; i++, offset += 4) { rowIndexFlags[i] = BreakIterator.getInt(buf, offset); } // load in the row-shift index l = BreakIterator.getInt(buf, offset); offset += 4; rowIndexShifts = new byte[l]; for (int i = 0; i < l; i++, offset++) { rowIndexShifts[i] = buf[offset]; } // load in the actual state table l = BreakIterator.getInt(buf, offset); offset += 4; table = new short[l]; for (int i = 0; i < l; i++, offset += 2) { table[i] = BreakIterator.getShort(buf, offset); } // finally, prepare the column map for supplementary characters l = BreakIterator.getInt(buf, offset); offset += 4; int[] temp3 = new int[l]; for (int i = 0; i < l; i++, offset += 4) { temp3[i] = BreakIterator.getInt(buf, offset); } supplementaryCharColumnMap = new SupplementaryCharacterData(temp3); }