Hi, What's the fastest method for outputting data to the display(console)? I know that System.out. is line buffered and it would be easier to output an entire buffer at once, instead of it being flushed after each newline character. The output is from a hashset, and it needs to stay in the same order it was read into the set in. Thanks for your time,
You can wrap System.out in a BufferedOutputStream to reduce unnecessary flushing. A bigger problem is your other requirement: > The output is from a hashset, and it needs to stay in the same > order it was read into the set in. A HashSet has no memory of the order in which elements were inserted - that's a property of a List, not a Set. If you do need to have the properies of a HashSet in addition to this requirement, then I would write a new class which contains both a HashSet and an ArrayList inside. Whenever you successfully add an element to the Set, you add it to the end of the List as well. The Set ensures that each element is unique, while the List remembers the order of insertion.