/* Count.java * Let's practice creating an output file. * Count from 1 to 100, and write the numbers to a file instead of * the screen. Here, I'm calling the output file stream "out" * so that we can use "out.printf" analogously to System.out.printf. */ import java.io.PrintStream; // for file output import java.io.FileNotFoundException; // in case can't open file public class Count { public static void main(String [] args) throws FileNotFoundException { // Open the output file. PrintStream out = new PrintStream("count.out"); // Here is the loop that prints the numbers. int num = 1; while (num <= 100) { out.printf("%d\n", num); num = num + 1; } } }