I am trying to read lines of input from a BufferedReader and output them in sorted order without any duplicate lines. I think that using a TreeSet would be my best option. Unfortunately I don't know how to get my input from the BufferedReader into the TreeSet.
This is what I have tried:
public static void doIt(BufferedReader r, PrintWriter w) throws IOException {
SortedSet<String> ts = new TreeSet<String>();
//make arrayList of bufferedReader Strings, add TreeSet, print
String[] lines;
for(String line : lines){
ts.add(line);
w.println(line);
}
This clearly doesn't work, but I'm at a loss for what to do to make it work? I am new to programming so any help would be greatly appreciated!