Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Java please!! /** * Opens and reads the contents of the input file specified in fileName. The input file is read * line by line.

Java please!!

/** * Opens and reads the contents of the input file specified in fileName. The input file is read * line by line. Each line is split into words and punction (excluding the apostrophe) and * stored in an ArrayList of Strings. These ArrayLists representing the line are stored in an * ArrayList of ArrayLists of Strings. Specifically, they are put in the ArrayList fileByLine * that is passed in as a parameter. * * For example, a file containing the following: * Lorem ipsum dolor sit amet, consectetur adipiscing elit. Don'ec elementum tortor in mauris * consequat vulputate. * * Would produce an ArrayList of ArrayLists containing 2 ArrayLists of Strings. * The first ArrayList would contain: * "Lorem", "ipsum", "dolor", "sit", "amet", ",", "consectetur", "adipiscing", "elit", ".", * "Don'ec", "elementum", "tortor", "in", "mauris" * The second Arraylist would contain: * "consequat", "vulputate", "." * * Note 1: The text file is assumed to be UTF-8. * Note 2: There are no assumption about the length of the file or the length of the lines. * Note 3: All single quotes (') are assumed to be apostrophes. * * When opening the file, any FileNotFoundException is caught and the error message * "Exception: File 'fileName' not found." followed by a new line is output, * where fileName is the name of the file that the method attempted to open. * * @param fileName The name of the input text file to parse. * @param fileByLine Reference to ArrayList to contain the contents of the file line by line, * where each line is an ArrayList of Strings. * @throws IOException if an I/O error occurs when closing the file. FileNotFoundException is * caught when opening the file. */ public static void readInputFile(String fileName, ArrayList > fileByLine) throws IOException

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Oracle Databases On The Web Learn To Create Web Pages That Interface With Database Engines

Authors: Robert Papaj, Donald Burleson

11th Edition

1576100995, 978-1576100998

Students also viewed these Databases questions

Question

LO2 Compare three types of individual incentives.

Answered: 1 week ago