/*============================================================================= | | NAME | | ModelFileParser.java | | DESCRIPTION | | Parser for *.mod model files. | | PUBLIC MEMBER FUNCTIONS | | | EXCEPTIONS | | | NOTES | | | BUGS | | | AUTHOR | | Sean E. O'Connor | | LEGAL | | Prentice Version 1.1 - An Artist's Software Apprentice. | Copyright (C) 2003-2009 by Sean Erik O'Connor. All Rights Reserved. | | Primpoly Version 10.4 - A Program for Computing Primitive Polynomials. | Copyright (C) 1999-2009 by Sean Erik O'Connor. All Rights Reserved. | | This program is free software: you can redistribute it and/or modify | it under the terms of the GNU General Public License as published by | the Free Software Foundation, either version 3 of the License, or | (at your option) any later version. | | This program is distributed in the hope that it will be useful, | but WITHOUT ANY WARRANTY; without even the implied warranty of | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | GNU General Public License for more details. | | You should have received a copy of the GNU General Public License | along with this program. If not, see . | | The author's address is artificer!AT!seanerikoconnor!DOT!freeservers!DOT!com | with !DOT! replaced by . and the !AT! replaced by @ | +============================================================================*/ package Model ; // Package name for this project. import java.io.* ; // BufferedReader, File import java.util.* ; // Collection classes import Prentice.* ; // Prentice stuff public class ModelFileParser { // Constructor. public ModelFileParser( String modelFileName ) { File modelFile = new File( modelFileName ) ; parse( modelFile ) ; } // Constructor. public ModelFileParser( File modelFile ) { parse( modelFile ) ; } private void parse( File modelFile ) { try { FileReader fileReader = new FileReader( modelFile ) ; BufferedReader reader = new BufferedReader( fileReader ) ; String line = null ; while ( (line = reader.readLine()) != null) { System.err.println( line ) ; } reader.close() ; } catch (IOException e) { System.err.println( "Could not parse the file." ) ; System.err.println( "Message :" + e.getMessage() ) ; System.err.println( "Stack trace" ) ; e.printStackTrace() ; } finally { } String [] testString = new String[ 4 ] ; testString[ 0 ] = "one" ; testString[ 1 ] = "two" ; testString[ 2 ] = "one" ; testString[ 3 ] = "three" ; Set s = new HashSet(); for (String a : testString) if (!s.add(a)) System.out.println("Duplicate: " + a); System.out.println(s.size()+" distinct words: "+s); ArrayList graph = new ArrayList() ; for (int i = 0 ; i < 5 ; ++i) { MyPoint p = new MyPoint() ; p.x = i ; p.y = 2 * i ; graph.add( p ) ; System.out.println( "adding element" + i ) ; } for (int i = 0 ; i < graph.size() ; ++i) { System.out.println( "point " + i + " = " + graph.get( i ).y ) ; } float [][] a ; a = new float[ 10 ][] ; OuterLoop: for (int i = 0 ; i < a.length ; ++i) { a[ i ] = new float[ i + 1 ] ; if (i == 5) break OuterLoop; // Exit loop } } // end parse } class MyPoint { int x ; int y ; MyPoint() { x = 0 ; y = 0 ; } }