// CSE 143, Autumn 2013 // Prints out a reversed version of a file and a second version of the same file // without plural words (words ending in "s") import java.io.*; import java.util.*; public class ReverseFile { public static void main(String[] args) throws FileNotFoundException { ArrayList allWords = new ArrayList(); Scanner input = new Scanner(new File("poem.txt")); while(input.hasNext()) { String word = input.next(); allWords.add(word); } for(int i = allWords.size() - 1; i >= 0; i--) { System.out.println(allWords.get(i)); } for(int i = allWords.size() - 1; i >= 0; i--) { if(allWords.get(i).endsWith("s")) { allWords.remove(i); } } System.out.println(allWords.toString()); } }