View Full Version : help please
sunklay69
09-24-2005, 03:49 AM
I was doing a program an I need help on one method
I need to check for a number and count how many times it is on the file
the only thing that I don't know how to do is the part that I need to read and count.
I'm doing it in java.
KeZZeR
09-24-2005, 11:48 AM
So you don't know how to read or count the file? Surely that means that you haven't attempted it because those 2 points are pretty much it.
Just break it down. First you need to obviously read the file in character by character. Then when you encounter a certain type of character simply increment an integer. That's pretty much it.
You should check out InputStreamReader which is passed as an object to a BufferedReader
sunklay69
09-26-2005, 07:38 PM
I know how to read the only thing is that I don't know how to count
Example how many a's are in the document?
this is the thing I trying to do but I think I'm not doing it right. Help me in everything that you can.
thank you
nikkiH
09-26-2005, 07:42 PM
Read the file character by character.
Create an empty hashtable (chars as keys, ints as values).
for each character in file do
-- look in hash for character
-- if exists increment counter
loop
vBulletin® v3.8.2, Copyright ©2000-2012, Jelsoft Enterprises Ltd.