Created
November 20, 2016 21:22
-
-
Save a-r-d/a60f2bd9ea61e07018249b639d51e266 to your computer and use it in GitHub Desktop.
Just a quick java iterator example.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// assume some stuff like this exists | |
ArrayList<String> lines = ... | |
BufferedWriter writer = ... | |
// get your iterator instance. | |
Iterator<String> iterator = lines.iterator(); | |
String write = null; | |
// iterate + check inside of the while loop condition test. | |
while (iterator.hasNext() && (write = iterator.next()) != null) { | |
writer.append(write); | |
writer.flush(); | |
writer.newLine(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment