如何让树集按字母顺序排序?并删除重复项......这让我疯了一天。也许我需要睡一觉。。
public static void main(String[] args) {
String fileName = args[0];
String words;
Scanner s = null;
Iterator itr;
try {
s = new Scanner(new BufferedReader(new FileReader(fileName)));
while (s.hasNext()) {
words = s.next();
TreeSet<String> ts = new TreeSet<String>();
ts.add(words);
System.out.println(ts);
}
} catch (FileNotFoundException fnfe) {
System.exit(0);
} finally {
if (s != null) {
s.close();
}
}
}