I want to print no. of a, b, c,etc... Special characte开发者_如何学JAVArs, vowels, consonants in file using Java. how to do that?
- create
map <char, int>
- read file char by char.
- if char in map -> map.put(map.get(char)+1) else map.put(char, 1)
- 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.
精彩评论