Link to home
Start Free TrialLog in
Avatar of usumle

asked on

How to write a program that uses Buffered Reader to read a text file

After I get  user-prompted input and output file names,  I need to write a program that uses  Buffered Reader (and Buffered Writer) to read a text file, line-by-line, and write a new copy of the file with the lines sorted alphabetically.   I cant figure out how to do this using the Collections Class define a sort with the following header       public void sort ( List list )    
that will take either an ArrayList or LinkedList of Strings as an argument and sorts them.
Avatar of sciuriware

A buffered Reader is just an extra 'motor' converting bytes into text and buffering for you.
The way you store your data is completely independent from that.
If you are going to read an arbitrary load of strings, use an ArrayList of Strings.
Use Arrays.sort(<your list>) only once (afterward).

I assume you know how to read and write the data itself .....
Avatar of drjustin

Link to home
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of usumle


ok , now it's starting to click,  thankks