/*============================================================================= | | 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-2008 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; version 2 | of the License. | | 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, write to the Free Software | Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. | | The author's address is artifex@seanerikoconnor.freeservers.com. | +============================================================================*/ 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 ; } }