This will be an exciting chapter. First we'll take a look at how to write to files using Java. To do this, we'll declare a mathematical sequence for the first 50 numbers of the mathematical sequence in which each number will be the sum of the previous two numbers. When we run the following program we will see these 50 numbers printed out to our System.out stream, and we will be able to view them in our console window:
package writingtofiles; public class WritingToFiles { public static void main(String[] args) { for(long number : FibonacciNumbers()) { System.out.println(number); } } private static long[] FibonacciNumbers() { long[] fibNumbers = new long[50]; fibNumbers[0] = 0; fibNumbers[1] = 1; for(int i = 2; i < 50; i++) { ...