cazaletm 0 Newbie Poster

Hello! Can anyone tell me how to make use of the End of Line constant (TT_EOL) when reading data from a file into a Vector? I understand that TT_EOL returns and int, while vectors only hold class types (Double in my case), so how can you compare the two? I would like my program to stop reading tokens into a vector when it reaches the end of the line in a text file. Here is my code, that produces an error stating that I cannot compare a String to an int:

public void dataRetrieve(String name)
		
	/**************************************************************************
	*Method Name: 	dataRetrieve
	*
	*Description:  	This method takes in the name variable and reads the file
	*				line by line, parsing each test name (String) and each test
	*				score (integer).  For each line, it adjusts all applicable 
	*               variables as necessary and keeps track of total tests and
	*               total scores by range (for each test). It will throw an IO 
	*               exception if there are problems reading from the file.  
	*				Reads file until no more lines.
	*			   	
	*		
	*Precondition:	Text file exists.	
	*		
	*Postcondition: Multiple variable values are updated to reflect all file
	*				input.  Total tests are counted.
	*
	*Author:  		Melissa M. Cazalet
	***************************************************************************/
		
		{
			try
			{
				BufferedReader inputStream = new BufferedReader(new FileReader(name));
			
				String trash = "No trash yet";
				testNames = new Vector<String>();
				while ((trash = inputStream.readLine()) !=null)
				{
					StringTokenizer st = new StringTokenizer(trash);	
					testNames.addElement(st.nextToken());

					lineCount++;
					
					Vector<Double> tempScores;
					while(st.nextToken()!= StreamTokenizer.TT_EOL)
						{
							tempScores = new Vector<Double>();
							tempScores.addElement(new Double(st.nextToken());
						}
							
					int index;
					double sum = 0;
					for(index = 0; index<tempScores.size(); index++)
						{
							sum = sum + tempScores.elementAt(index);		
						}
					double average = sum/tempScores.size();
					testMeans.addElement(average);
					
				}
				
				inputStream.close();
			}
			catch(IOException e)
			{
				System.out.println("Problem reading from file.");
			}

Thanks for any/all help!

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.18 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.