Problems:. 1. Write a method called arrayBuilder that t

Added on - 16 Sep 2019

  • 1

    pages

  • 277

    words

  • 112

    views

  • 0

    downloads

Showing pages 1 to 1 of 1 pages
Problems:1. Write a method called arrayBuilder that takes an integer parameter (length), returnsan 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 returnedPass the array and a file name to the writeArray methodPass the file name to the readFile methodIn the main method loop through the returned ArrayList to printits contents to the command line
desklib-logo
You’re reading a preview
card-image

To View Complete Document

Become a Desklib Library Member.
Subscribe to our plans

Unlock This Document