I need some help with an assignment - to read from a .txt file and count paragraphs, lines, words and characters. I've managed to write a program to read the file, and another one to count - but I've run into problems trying to incorporate the two.

I've sent myself loopy trying to sort it out so would really appreciate help. I don't think I will ever be a threat to the programmers of the world but need to pass this module so I can concentrate on the things I am good at!

Getting 'cannot find symbol' errors on lines 31, 53 & 54

import java.io.*;
import java.util.*;

public class AnalyzerTwo
public static void main(String[] args) //main method
	throws IOException
        try {
			//File reader to read the file named in command line one character at a time 
			FileReader input = new FileReader(args[0]);
			//Filter FileReader through a Buffered read to read a line at a time 
			BufferedReader buffer = new BufferedReader(input);
            int paragraph = 1;	// Line number of count 
            boolean endfile = false;
		while (!endfile)
			int characters = 0;
			int words = 0;
			int lines = 0;
			while (true) //loop
				String hold =  new hprintln(); //constuctor
				System.out.println ("");	
				String line; // String that holds line
				if (line == null)
				endfile = true;
				StringTokenizer tokenizer = new StringTokenizer (line);
				if (!tokenizer.hasMoreTokens())	

				while (tokenizer.hasMoreTokens())
				characters += line.length();
				hprintln("+" + line);
				hprintln("." + characters + "" + words + "" + ""+ lines);
			if ( lines>0)
				( "Paragraph" + paragraph + "." +lines + "lines," 
				+ words + "words," + characters + "characters" );
				++ paragraph;

		}catch (IOException e)
			// If exception generated, print a stack trace
   // end main
9 Years
Discussion Span
Last Post by Cornflower

"Cannot find symbol" means you are using a class, method, or variable that hasn't been defined. In this case, you are calling "hprintln()", which doesn't exist in that file.


Thanks - I thought I had done that (about 10 time in different positions and with differing words) - but I'll try again!

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.