1Set<String> tokens = new HashSet<String>(Arrays.asList(s.split("\n")));
2StringBuilder resultBuilder = new StringBuilder();
3
4boolean first = true;
5for(String token : tokens) {
6 if(first) first = false;
7 else resultBuilder.append("\n")
8
9 resultBuilder.append(token);
10}
11
12String result = resultBuilder.toString();
13