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 09:00
Which best compares appointments and events in outlook 2010appointments have a subject man, and events do notappointments have a specific date or range of dates, and events do notappointments have a start and end time of day, and events do notappointments have a location option, and events do not
Answers: 2
question
Computers and Technology, 23.06.2019 15:30
The processing of data in a computer involves the interplay between its various hardware components.
Answers: 1
question
Computers and Technology, 23.06.2019 22:30
Jamie has to enter the names, employee id’s, and income of a group of employees into a worksheet. which option will jamie use to describe the data
Answers: 3
question
Computers and Technology, 24.06.2019 02:00
Write an expression that will cause the following code to print "equal" if the value of sensorreading is "close enough" to targetvalue. otherwise, print "not equal". ex: if targetvalue is 0.3333 and sensorreading is (1.0/3.0), output is:
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
Mathematics, 15.01.2022 22:10
question
Mathematics, 15.01.2022 22:10
question
Mathematics, 15.01.2022 22:10
question
Mathematics, 15.01.2022 22:20
Questions on the website: 13722367