java stringbuilder filter same lines

Solutions on MaxInterview for java stringbuilder filter same lines by the best coders in the world

showing results for - "java stringbuilder filter same lines"
Maria José
30 Jul 2018
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
similar questions
queries leading to this page
java stringbuilder filter same lines