I want to print no. of a, b, c,etc... Special characters, vowels, consonants in file using Java. how to do that?
+1
A:
- Open the file
- Go through the file character by character.
- If the current char matches the char you want,increment the counter by one
- Detect end of file (EOF) and print the counter value.
Read File Handling , InputStream
Give it a try and if you are stuck at something specific,come back with the specific question.
chedine
2010-09-06 05:59:38
+2
A:
- create
map <char, int>
- read file char by char.
- if char in map -> map.put(map.get(char)+1) else map.put(char, 1)
foret
2010-09-06 06:00:52
There is no such thing as a `Map <char, int>`. It would have to be a map of wrapper types: `Map <Character, Integer>`
seanizer
2010-09-06 06:58:18
I know. I just don't really want to chew everything for topic-starter, because it really looks like homework. Anyway, it is very basic thing, and if topic-starter doesn't know them, i'd recommend to spend some time on learning basics.
foret
2010-09-06 07:20:28