Question: i want java code for Write an formatted binary file open _ in _ newfullscreen 1 / 1 0 In the previous lab, we read
i want java code for Write an formatted binary file
openinnewfullscreen
In the previous lab, we read a formatted binary file and displayed its results. In this lab, we will write a formatted binary file using the DataOutputStream class wrapped around a FileOutputStream object.
The input to your program will be a file name to write to a sequence of characters as a String a sequence of integers, and a seequence of doubles.
For example, given the input
output.dat Character sequence
Your program would open a file called Input.dat for writing through the DataOutputStream interface.
If would read the character sequence it will be a single line of charactersIt would then read the sequence of integers. Then it would read the seequence of doubles. Each of these sequences may be of arbitrary length.
For each of these sequences, your program will first write a short value to Input.dat that is the size of the sequence, followed by the sequence a sequence of characters, integers, and doubles using the appropriate DataOutputStream method. The above input would result it a file Input.dat containing
Character sequence
where the values in are bit short values, the values in are bit int values, and the values in are bit double values. The character sequence is written as a sequence of two bytes.
There are bytes of characters, bytes of integers, and bytes of doubles. There are bytes for the three lengths. bytes total. If you run your program with the input data above, your files should show an new file output.dat. If you click the three dots to the right and select Download, you should see a dowload binary file with bytes.
STUDENTOUTPUT
Character sequence
EXPECTEDOUTPUT
Character sequence
: Medium Binary File Test
SHUDENIOUTPUT
EXPECTEDOUTPUT
This is a longer file that contains a This is a longer file that contains a bunch of different characters and num bunch of different characters and numb ber and so on er and so on
quad
: Long Binary Flle Test
ipped, the internal buffer is refilled as necessary from the contained input stream, many bytes at a time. The mar k operation remembers a point in the i nput stream and the reset operation ca uses all the bytes read since the most recent mark operation to be reread be fore new bytes are taken from the cont ained input stream.
pped, the internal buffer is refilled as necessary from the contained input stream, many bytes at a time. The mark operation remembers a point in the in put stream and the reset operation cau ses all the bytes read since the most recent mark operation to be reread bef ore new bytes are taken from the conta ined input stream.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
