PrintWriter to multiple files
in
Programming Questions
•
2 years ago
Hi all, I'm trying to split a stream of numbers into different text files using PrintWriter. A simplified pseudo-code example:
Suggestions?
- // create a random number
int randomNumber = int(random(0,10));
PrintWriter output;
// depending on what that number is, write to a different file
if (randomNumber == 0) {
output = createWriter("0.txt");
output.println(randomNumber);
}
if (randomNumber == 1) {
output = createWriter("1.txt");
output.println(randomNumber);
}
output.flush();
output.close();
Suggestions?
1