// CSE 143, Winter 2011, Marty Stepp // This program uses recursion to print the lines of a file 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("poem.txt")); reverseLines(input); } // Prints the lines of the given input file in reverse order, recursively. public static void reverseLines(Scanner input) { if (input.hasNextLine()) { // at least 1 line to read String line = input.nextLine(); reverseLines(input); System.out.println(line); } } }