DOC PREVIEW
OSU CSE 1223 - CL13A

This preview shows page 1 out of 2 pages.

Save
View full document
Premium Document
Do you want full access? Go Premium and unlock all 2 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

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

OSU CSE 1223 - CL13A

Documents in this Course
PRO12A

PRO12A

3 pages

PRO11A

PRO11A

4 pages

PRO10A

PRO10A

3 pages

PRO9A

PRO9A

3 pages

PRO8A

PRO8A

3 pages

PRO7A

PRO7A

2 pages

PRO6A

PRO6A

2 pages

PRO4A

PRO4A

3 pages

PRO3A

PRO3A

3 pages

CL11B

CL11B

2 pages

CL11A

CL11A

2 pages

CL10A

CL10A

2 pages

CL5A

CL5A

2 pages

Load more
Download CL13A
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view CL13A and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view CL13A and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?