code:<HR>Code:package Assignment1;<P>/** * Title: * Description: * Copyright: Copyright (c) 2002 * Company: * @author * @version 1.0 */ import java.io.*; import java.util.*; public class Assignment1 {<P> public Assignment1() {<P> try { //open the text file BufferedReader DataIn = new BufferedReader(new FileReader("data.txt"));<P> //now find the number of lines int numberOfLines = 0; String inputLine = DataIn.readLine(); while (inputLine != null) { numberOfLines++; } DataIn.close();<P> //now make the arrays BufferedReader DataIn2 = new BufferedReader(new FileReader("FileName")); String[][] a = new String[numberOfLines][]; StringTokenizer line = DataIn2.readLine() ;<P> for(int x=0; x>=numberOfLines; x++) while (line != null) { int wordCounter = 0; while (line.hasMoreTokens()) { line.nextToken(); wordCounter++; a[x] = new String[wordCounter]; } } DataIn2.close();<P> //now fill them in BufferedReader DataIn3 = new BufferedReader(new FileReader("FileName")); StringTokenizer lineForFilling = null; while (lineForFilling != null) {<P> //text }<P> }<P> //some exceptions relating to file i/o catch( FileNotFoundException e ) { System.out.println("file data.txt not found or could not be opened") ; } catch( IOException e ) { System.out.println( "Error reading from file data.txt" ); }<P>}//close try }//close Assignment 1
The error I get in JBuilder is
code:<HR>Code:"Assignment1.java": Error #: 354 : incompatible types; found: java.lang.String, required: java.util.StringTokenizer at line 33, column 44
I know this program is a mess, honestly, I'm not a programmer, I'm an EE at a school where they tie the two together very closely. So I have no interest in suggestions on how to improve it (although I thank anyone who would have made suggestions along those lines), as it would be acedemic dishonesty.
Thanks
Noel
PS- right now it doesn't do anything, just runs.