private void loadBinary(InputStream is) throws IOException {
  DataInputStream dis=new DataInputStream(is);
  if (dis.readInt() != MAGIC) {
    throw new Error("Bad LTS binary file format");
  }
  if (dis.readInt() != VERSION) {
    throw new Error("Bad LTS binary file version");
  }
  int phonemeTableSize=dis.readInt();
  phonemeTable=new ArrayList(phonemeTableSize);
  for (int i=0; i < phonemeTableSize; i++) {
    String phoneme=dis.readUTF();
    phonemeTable.add(phoneme);
  }
  int letterIndexSize=dis.readInt();
  letterIndex=new HashMap();
  for (int i=0; i < letterIndexSize; i++) {
    char c=dis.readChar();
    int index=dis.readInt();
    letterIndex.put(Character.toString(c),new Integer(index));
  }
  int stateMachineSize=dis.readInt();
  stateMachine=new Object[stateMachineSize];
  for (int i=0; i < stateMachineSize; i++) {
    int type=dis.readInt();
    if (type == FinalState.TYPE) {
      stateMachine[i]=FinalState.loadBinary(dis);
    }
 else     if (type == DecisionState.TYPE) {
      stateMachine[i]=DecisionState.loadBinary(dis);
    }
 else {
      throw new Error("Unknown state type in LTS load");
    }
  }
}

private void loadBinary ( InputStream is ) throws IOException { DataInputStream dis = new DataInputStream ( is ) ; if ( dis . readInt ( ) != MAGIC ) { throw new Error ( "Bad LTS binary file format" ) ; } if ( dis . readInt ( ) != VERSION ) { throw new Error ( "Bad LTS binary file version" ) ; } int phonemeTableSize = dis . readInt ( ) ; phonemeTable = new ArrayList ( phonemeTableSize ) ; for ( int i = 0 ; i < phonemeTableSize ; i ++ ) { String phoneme = dis . readUTF ( ) ; phonemeTable . add ( phoneme ) ; } int letterIndexSize = dis . readInt ( ) ; letterIndex = new HashMap ( ) ; for ( int i = 0 ; i < letterIndexSize ; i ++ ) { char c = dis . readChar ( ) ; int index = dis . readInt ( ) ; letterIndex . put ( Character . toString ( c ) , new Integer ( index ) ) ; } int stateMachineSize = dis . readInt ( ) ; stateMachine = new Object [ stateMachineSize ] ; for ( int i = 0 ; i < stateMachineSize ; i ++ ) { int type = dis . readInt ( ) ; if ( type == FinalState . TYPE ) { stateMachine [ i ] = FinalState . loadBinary ( dis ) ; } else if ( type == DecisionState . TYPE ) { stateMachine [ i ] = DecisionState . loadBinary ( dis ) ; } else { throw new Error ( "Unknown state type in LTS load" ) ; } } }
loads the lts rules from the given binary input stream . the input stream is not closed after the rules are read .
