Java Forum

Ask Question   UnAnswered
Home » Forum » Java       RSS Feeds

Processing text file

  Asked By: Adelina    Date: Jun 06    Category: Java    Views: 946

I'm a beginner at java and would like to know how to process a
textfile containing names using java.

1. Counting the number of same names down the list.
2. Printing out only the distinct names on the list with the counted
number from 1.



2 Answers Found

Answer #1    Answered By: Calandre Bernard     Answered On: Jun 06

I think you must use a java.io.BufferedReader (or a
java.io.InputStreamReader with a java.io.FileInputStream if you need
to process  a special character encoding other than system default) to
read the file. You can use a java.io.StreamTokenizer to tokenize file
content. Then you can use a java.util.TreeMap to count the names. The
TreeMap.keySet() gives you the names  and the value associated with
each key in the map can be an Integer showing the number  of its

Answer #2    Answered By: Arron Lee     Answered On: Jul 23

Yup indeed, a 3rd party SDK is neccessary for you to process text file.

Didn't find what you were looking for? Find more on Processing text file Or get search suggestion and latest updates.