question: public void readOldFormat ( Reader reader ) throws Exception { StreamTokenizer tokenizer ; int currentToken ; double firstIndex , secondIndex , weight ; tokenizer = new StreamTokenizer ( reader ) ; initialize ( ) ; tokenizer . commentChar ( '%' ) ; tokenizer . eolIsSignificant ( true ) ; while ( StreamTokenizer . TT_EOF != ( currentToken = tokenizer . nextToken ( ) ) ) { if ( currentToken == StreamTokenizer . TT_EOL ) { continue ; } if ( currentToken != StreamTokenizer . TT_NUMBER ) { throw new Exception ( "Only numbers and comments allowed " + "in cost file!" ) ; } firstIndex = tokenizer . nval ; if ( ! Utils . eq ( ( int ) firstIndex , firstIndex ) ) { throw new Exception ( "First number in line has to be " + "index of a class!" ) ; } if ( ( int ) firstIndex >= size ( ) ) { throw new Exception ( "Class index out of range!" ) ; } if ( StreamTokenizer . TT_EOF == ( currentToken = tokenizer . nextToken ( ) ) ) { throw new Exception ( "Premature end of file!" ) ; } if ( currentToken == StreamTokenizer . TT_EOL ) { throw new Exception ( "Premature end of line!" ) ; } if ( currentToken != StreamTokenizer . TT_NUMBER ) { throw new Exception ( "Only numbers and comments allowed " + "in cost file!" ) ; } secondIndex = tokenizer . nval ; if ( ! Utils . eq ( ( int ) secondIndex , secondIndex ) ) { throw new Exception ( "Second number in line has to be " + "index of a class!" ) ; } if ( ( int ) secondIndex >= size ( ) ) { throw new Exception ( "Class index out of range!" ) ; } if ( ( int ) secondIndex == ( int ) firstIndex ) { throw new Exception ( "Diagonal of cost matrix non-zero!" ) ; } if ( StreamTokenizer . TT_EOF == ( currentToken = tokenizer . nextToken ( ) ) ) { throw new Exception ( "Premature end of file!" ) ; } if ( currentToken == StreamTokenizer . TT_EOL ) { throw new Exception ( "Premature end of line!" ) ; } if ( currentToken != StreamTokenizer . TT_NUMBER ) { throw new Exception ( "Only numbers and comments allowed " + "in cost file!" ) ; } weight = tokenizer . nval ; if ( ! Utils . gr ( weight , 0 ) ) { throw new Exception ( "Only positive weights allowed!" ) ; } setCell ( ( int ) firstIndex , ( int ) secondIndex , new Double ( weight ) ) ; } }
target:  Loads a cost matrix in the old format from a reader. Adapted from code once sitting in Instances.java