subject

Design a class FileArray that has a static method named writeArray. The method should take two arguments: the name of a file and a reference to an int array. The file should be opened as a binary file, the contents of the array should be written to the file, and then the file should be closed. Write a second static method in the class FileArray named readArray. The method should take two arguments: the name of a file and a reference to an int array. The file should be opened, data should be read from the file and written into the array, and then the file should be closed. FileArrayDemoDemonstrate both methods in a class called FileArrayDemo with the main method. Import both java. io.* and java. util.*;Creates a Scanner. Set a flag to false. while flag is falseUnder a try-catch-finally:Under try:Requests, and reads in the size of an int array called inputNumbers. It then creates the array and requests and reads in the values of the array. It also creates an output array of the same size called outputNumbers. Also request and read in the name of an output file of type .dat. It then creates the array and requests and reads in the values of the array. Call writeArray with references to the outputfile name and the array inputNumbers. Call readArray with references to the outputfile name and the array outputNumbers. Test for the various error conditions. Print out the output file. Set flag to trueUnder catch:Catch any InputMismatchException and print the trace (see output). – In this case set the flag to trueCatch and print the trace (see output).Catch and print the trace (see output).Catch any IOException and print the trace (see output).Under finally:Print "Program Completed"Sample Inputs/OutputsPlease enter the number of integers to enter:8.2InputMismatchjava. util. InputMismatchException at java. base/java. util. Scanner. throwFor(Scanner. java:939) at java. base/java. util. Scanner. next(Scanner. java:1594) at java. base/java. util. Scanner. nextInt(Scanner. java:2258) at java. base/java. util. Scanner. nextInt(Scanner. java:2212) at FileArrayDemo. main(FileArrayDemo. java:21)Program Loop CompletedPlease enter the number of integers to enter:-8.lang.: -8 at FileArrayDemo. main(FileArrayDemo. java:22)Program Loop CompletedPlease enter the number of integers to enter:4Please enter the name of the .dat file you want to write to and then read from;xxx. datPlease enter 4 integers:9 -9 12 54The numbers read from the file are:9 -9 12 54Program Loop Completed

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 05:20
Which operating system is a version of linux?
Answers: 1
question
Computers and Technology, 23.06.2019 09:30
Which of the following tasks is an audio technician most likely to perform while working on a nature documentary? (select all that apply). eliminating potentially distracting background noise adding sound effects making sure the lighting is adequate for a particular scene changing the narration to better match the mood of the documentary
Answers: 3
question
Computers and Technology, 23.06.2019 11:00
Sports and entertainment class, your goal is to increase attendance and make a profit for a game by getting your team on a winning track with total salaries less than $3,000,000
Answers: 3
question
Computers and Technology, 23.06.2019 11:30
The most accurate readings that you can take on an analog vom are when the meter's pointer is at the a. center scale. b. extreme right. c. near right. d. extreme left.
Answers: 1
You know the right answer?
Design a class FileArray that has a static method named writeArray. The method should take two argum...
Questions
question
Business, 14.03.2022 15:10
question
Mathematics, 14.03.2022 15:10
Questions on the website: 13722363