Computers and Technology

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

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 15:10, AleciaCassidy
Consider a direct-mapped cache with 216 words in main memory. the cache has 16 blocks of 8 words each. it is a word-addressable computer (rather than a byte-addressable computer which we normally discuss). (a) how many blocks of main memory are there? (b) what is the format of a memory address as seen by the cache, that is, what are the sizes of the tag, cache block, and block offset fields (if they apply)? (c) to which cache block will the memory reference db6316 map?
Answers: 1
image
Computers and Technology, 24.06.2019 16:30, Dajuan2x
Jenny needs to record the names of 30 students, write down the subjects they studied, and note their grades in each subject after the midsemester exams and the end-of-semester exams. she divides the midsemester and end-of-semester information into two separate worksheets, sheet 1 and sheet 2. how will she rename the two worksheets?
Answers: 2
image
Computers and Technology, 24.06.2019 20:20, jdkrisdaimcc11
Write python code that prompts the user to enter his or her age and assigns the user’s input to an integer variable named age.
Answers: 1
image
Computers and Technology, 25.06.2019 00:40, lexieprochaskaaa
Roger ginde is developing a program in supply chain management certification for managers. ginde has listed a number of activities that must be completed before a training program of this nature could be conducted. the activities, immediate predecessors, and times appear in the accompanying table: activity immediate predecessor(s) time (days) a -βˆ’ 44b -βˆ’ 55 c -βˆ’ 11 d b 1010 e a, d 55 f c 55 g e, f 1010 calculate the slack time. show the details.
Answers: 2
Do you know the correct answer?
Design a class FileArray that has a static method named writeArray. The method should take two argum...

Questions in other subjects:

Konu
Health, 22.07.2019 22:30
Konu
History, 22.07.2019 22:30
Konu
Mathematics, 22.07.2019 22:30