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
| 1 pages
| 277 words
| 217 views
Trusted by 2+ million users, 1000+ happy students everyday
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
Found this document preview useful?
You are reading a preview Upload your documents to download or Become a Desklib member to get accesss