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
open_in_newfullscreen1/10
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 1233.14156291.2
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 characters).It 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
18>Character sequence3>{1}{2}{3}2>[3.1415629][1.2]
where the values in > are 16 bit (short) values, the values in {} are 32 bit (int) values, and the values in [] are 64 bit (double) values. The character sequence is written as a sequence of two bytes.
There are 2*18=36 bytes of characters, 3*4=12 bytes of integers, and 2*8=16 bytes of doubles. There are 3*2=6 bytes for the three lengths. 36+12+16+6=70 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 70 bytes.
STUDENT_OUTPUT
Character sequence
1
2
3
3.1415629
1.2
EXPECTED_OUTPUT
Character sequence
1
2
3
3.1415629
1.2
2: Medium Binary File Test
SHUDENI_OUTPUT
EXPECTED_OUTPUT
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 3.1415629100100000 and so on.1000000 er 3.1415629100100000 and so on.
1000000
2034020340
\(1002003030\quad 1002003030\)
23003
23003
3: 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.
1
2
3
4
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.
1
2
3
4
i want java code for Write an formatted binary

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!