Skip to main content
2 of 3
deleted 55 characters in body
MatBanik
  • 26.9k
  • 40
  • 119
  • 179

here I'm using a hashset to store seen lines

Scanner scan;//input Set<String> lines = new LinkedHashSet<String>(); StringBuilder strb = new StringBuilder(); while(scan.hasNextLine()){ String line = scan.nextLine(); if(lines.add(line)) strb.append(line); } 
ratchet freak
  • 48.4k
  • 5
  • 76
  • 114