Write a method called arrayBuilder that takes an integer parameter (length), returns an array of Strings, and is declared to throw an Exception. (2 points) Call arrayBuilder passing the size of the array that you want returned Pass the array and a file name to the writeArray method Pass the file name to the readFile method In the main method loop through the returned ArrayList to print its contents to the command line
ArrayBuilder and WriteArray
Added on 2019-09-16
BookmarkShareRelated Documents
Problems:1. Write a method called arrayBuilder that takes an integer parameter (length), returns an array of Strings,and is declared to throw an Exception. If the parameter passed is a negative value, throwan Exception. Otherwise, build and return an array of Strings with size based onthe parameter passed. (2 points)2. Write a method called writeArray that takes two parameters: an array of Strings anda String (fileName), and returns nothing. Write the array of Strings to a text filenamed using the fileName parameter. Make sure to catch any Exception thatmight be thrown. (3 points)3. Write a method called readFile that takes a String parameter (fileName) andreturns an ArrayList of Strings. The method reads the text file (fileName) andpopulates the ArrayList with an element for each line in the file. The returns thepopulated ArrayList. Make sure to catch any Exception thatmight be thrown. (3 points)4. Call each of the methods above from the main method.The pseudocode for the main method will be as given below.Make sure to catch any Exception thatmight be thrown. (2 points) Call arrayBuilder passing the size of the array that you want returned Pass the array and a file name to the writeArray method Pass the file name to the readFile method In the main method loop through the returned ArrayList to print its contents to the command line
End of preview
Want to access all the pages? Upload your documents or become a member.
Related Documents
Methodology for Desklib Online Library SEOlg...
|3
|1530
|187
The following Java program prompts the user and reads in a linelg...
|3
|489
|326
CIS 120 Exam 2 Programming Question.lg...
|1
|467
|165
C++ Programs for Vehicle Warranty, Person and Subclasseslg...