// Erika Wolfe // CSE 143, Section ZZ // This program reads in a file and prints out the lines // in reverse order import java.io.*; import java.util.*; public class ReverseFile { public static void main(String[] args) throws FileNotFoundException { Scanner input = new Scanner(new File("words.txt")); reverse(input); } // print the lines of the file in the Scanner // in reverse order public static void reverse(Scanner input) { // base case: what is the easiest file to reverse? - empty if (input.hasNextLine()) { // recursive case: what is the smallest amount I can // reverse and still get closer to the solution? String line = input.nextLine(); reverse(input); System.out.println(line); } } }