Lab13a java A program that prompts the user for an input file name and if that file exists displays each line of that file in reverse order Used to practice simple File I O and breaking code up into methods as well as a first step to implementing Lab13b java reversing the entire file and Lab13c java writing output to a separate output file author ENTER YOUR NAMES HERE ClosedLab13a author version 20141010 package osu cse1223 import java io import java util public class ClosedLab13a public static void main String args throws FileNotFoundException Fill in the body String filename data Scanner inScanner new Scanner System in filename getFileName inScanner File file new File filename if file exists System out println File named filename does not exist else Scanner input new Scanner file while input hasNextLine data input nextLine System out println reverse data Given a Scanner as input prompts the user to enter a file name If given an empty line respond with an error message until the user enters a non empty line Return the string to the calling program Note that this method should NOT try to determine whether the file name is an actual file it should just get a valid string from the user private static String getFileName Scanner inScanner System out print Enter the name of your input file return inScanner next Given a String as input return the reverse of that String to the calling program private static String reverse String inString int i String rev for i inString length 1 i 0 i rev rev inString charAt i return rev
View Full Document