// Hunter Schafer // CSE 143, Section AZ // TA: Hunter Schafer // This program reads in a file and prints out the lines in reverse order import java.io.File; import java.io.FileNotFoundException; import java.util.ArrayList; import java.util.Scanner; import java.util.Stack; public class ReverseFile { public static void main(String[] args) throws FileNotFoundException { Scanner input = new Scanner(new File("words.txt")); // First read in lines Stack allLines = new Stack(); while (input.hasNextLine()) { String line = input.nextLine(); allLines.push(line); } // Print in reverse while (!allLines.isEmpty()) { System.out.println(allLines.pop()); } } }